AWS Certified Developer – Associate — Question 266
A developer has an application that pushes files from an on-premises local server to an Amazon S3 bucket. The application uses an AWS access key and a secret key that are stored on the server for authentication. The application calls AWS Security Token Service (AWS STS) to assume a role with access to perform the S3 PUT operation to upload the file.
The developer is migrating the server to an Amazon EC2 instance. The EC2 instance is configured with an IAM instance profile in the same AWS account that owns the S3 bucket.
What is the MOST secure solution for the developer to use to migrate the automation code?
Answer options
- A. Remove the code that calls the STS AssumeRole operation. Use the same access key and secret key from the server to access the S3 bucket.
- B. Remove the access key and the secret key. Use the STS AssumeRole operation to add permissions to access the S3 bucket.
- C. Remove the access key, the secret key, and the code that calls the STS AssumeRole operation. Use an IAM instance profile role that grants access to the S3 bucket.
- D. Remove the access key, the secret key, and the code that calls the STS AssumeRole operation. Create a new access key and secret key. Use the new keys to access the S3 bucket.
Correct answer: C
Explanation
Using an IAM instance profile is an AWS best practice for EC2 instances because it eliminates the need to manage, store, or rotate long-term AWS credentials. By removing the hardcoded keys and the redundant STS AssumeRole code, the application securely and automatically retrieves temporary credentials from the EC2 instance metadata. Options A, B, and D are less secure or overly complex because they either maintain long-term credentials or perform unnecessary STS API calls that the instance profile handles natively.