A developer is building a batch application that will run on an Amazon EC2 instance and needs read access to an Amazon S3 bucket. To follow security best practices, how should the developer grant S3 read access to the application running on the EC2 instance?
Choose an answer
Tap an option to check your answer.
Correct answer: Create an IAM policy with the required permissions, attach that policy to an IAM role, and assign the role to the EC2 instance profile..
Why this is the answer
The most secure and recommended method is to create an IAM policy with the necessary S3 read permissions, attach this policy to an IAM role, and then assign that role to the EC2 instance profile. This allows the EC2 instance to assume the role and temporarily obtain the permissions without storing credentials directly on the instance, adhering to the principle of least privilege and credential rotation. Attaching an IAM group to an EC2 instance profile is incorrect because instance profiles are designed to assume roles, not groups. Assigning an IAM user to an EC2 instance profile is also incorrect and a security risk, as it would require managing user credentials on the instance. Using IAM web identity federation is for external identity providers (like Google or Facebook) to grant temporary access, not for EC2 instances to access AWS services directly.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed