AWS Certified Solutions Architect – Professional — Question 461

You have an application running on an EC2 instance which will allow users to download files from a private S3 bucket using a pre-signed URL. Before generating the URL, the application should verify the existence of the file in S3.
How should the application use AWS credentials to access the S3 bucket securely?

Answer options

Correct answer: B

Explanation

Using an IAM role for EC2 is the AWS-recommended best practice for securely granting applications on EC2 instances access to other AWS services like S3. This method avoids hardcoding or storing long-term credentials on the instance, as the AWS SDK automatically retrieves temporary security credentials from the EC2 instance metadata. Storing access keys in source code, local directories, or user data (Options A, C, and D) exposes credentials and violates security best practices.