A company is migrating a noncritical application to a single EC2 instance. The application will read and write objects in Amazon S3. Following AWS security best practices, which method should the company use to grant the application access to S3?
Choose an answer
Tap an option to check your answer.
Correct answer: Create an IAM role that grants only the required S3 permissions and attach that role to the EC2 instance..
Why this is the answer
Attaching an IAM role to an EC2 instance is the most secure and recommended method for granting AWS service access. This approach eliminates the need to embed credentials directly into application code, which is a significant security risk. The role grants temporary credentials that are automatically rotated, reducing the impact of a potential compromise. Furthermore, granting only the required S3 permissions adheres to the principle of least privilege, minimizing the attack surface. Using AdministratorAccess (whether with a role or user) is overly permissive and violates the principle of least privilege. Embedding access keys and secret keys directly in application code or on the instance is highly insecure, as these static credentials could be exposed if the instance is compromised.
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