Question #907
A company is migrating a legacy application from its on-premises infrastructure to AWS. As part of the initial phase, the application is being refactored and deployed on a single Amazon EC2 instance. The application requires access to an Amazon RDS database. The company wants to ensure secure and efficient communication between the EC2 instance and the RDS database while adhering to AWS security best practices.
Which approach should the company implement to enable the application to interact with Amazon RDS securely?
Create an IAM role with full administrative privileges to AWS. Attach the role to the EC2 instance.
Create an IAM user with the AmazonRDSFullAccess policy. Generate access keys and embed them directly into the application code to authenticate RDS requests via the AWS SDK.
Create an IAM role with the minimum necessary permissions for Amazon RDS access. Attach the role to the EC2 instance.
Create an IAM user with a policy granting the required RDS permissions. Store the access key and secret key in a configuration file on the EC2 instance and reference them in the application code.
Explanation
Answer C is correct because:
1. IAM Roles for EC2: Attaching an IAM role to the EC2 instance allows the application to securely access AWS services without hardcoding credentials. AWS automatically manages temporary credentials, reducing the risk of exposure.
2. Principle of Least Privilege: The role should grant only the minimum permissions required for the application to interact with RDS, minimizing potential damage from compromised instances.
3. Avoiding Long-Term Credentials: Options B and D involve embedding or storing access keys, which are long-term credentials vulnerable to exposure. IAM roles eliminate this risk.
4. No Over-Privileged Access: Option A's 'full administrative privileges' violate security best practices. Option C ensures permissions are scoped to RDS requirements.
Key Points:
- Always use IAM roles for EC2 instances instead of IAM users/access keys.
- Apply the principle of least privilege to IAM policies.
- Temporary credentials via roles are more secure than static access keys.
Answer
The correct answer is: C