AWS Certified Developer – Associate (DVA-C02) — Question 31

An application that is hosted on an Amazon EC2 instance needs access to files that are stored in an Amazon S3 bucket. The application lists the objects that are stored in the S3 bucket and displays a table to the user. During testing, a developer discovers that the application does not show any objects in the list.
What is the MOST secure way to resolve this issue?

Answer options

Correct answer: B

Explanation

The correct answer is B because adding the S3:ListBucket permission to the IAM instance profile allows the application running on the EC2 instance to list the objects in the S3 bucket securely. Option A is incorrect as it grants broader access than necessary, while C does not address the permissions required by the EC2 instance but rather by the developer. Option D, while it modifies the bucket policy, is less secure than using IAM roles assigned directly to the EC2 instance.