Question

Difficulty: EasyIAM Policies and Roles

An application hosted on an Amazon EC2 instance needs to securely retrieve configuration settings from an Amazon S3 bucket. A developer is tasked with setting up the necessary IAM permissions using security best practices. Which configuration steps should the developer perform to grant the application access to the S3 bucket? (Select TWO.)

  1. Create an IAM role with a trust policy that permits the ec2.amazonaws.com service principal to assume the role.Answer
  2. Associate the IAM role with the EC2 instance by attaching an EC2 instance profile containing the role to the instance.Answer
  3. C
    Hardcode the Access Key ID and Secret Access Key of an IAM user with S3 permissions inside the application's source code.
  4. D
    Attach a permissions policy to the IAM role that lists ec2.amazonaws.com as the Principal in the policy statement.
  5. E
    Configure an Amazon ECS Task Execution Role with S3 access permissions and assign it to the EC2 instance.

Answer

To allow the application on the EC2 instance to access the S3 bucket, the developer must create an IAM role with a trust policy that allows the EC2 service to assume the role, and then associate the IAM role with the EC2 instance using an EC2 instance profile.
Securing access to AWS services from an Amazon EC2 instance requires creating an IAM role with a trust policy that allows the EC2 service principal to assume the role. The role must then be attached to the EC2 instance via an EC2 instance profile, enabling the application to automatically assume the role and access S3 using temporary credentials.

Step-by-Step Solution

1
Establish trust for the EC2 service.
Create an IAM role containing a trust policy that permits the ec2.amazonaws.com service principal to call the sts:AssumeRole API action.
This enables AWS to delegate permissions to the EC2 service so it can obtain temporary credentials for the instance.
2
Associate the role with the compute resource.
Attach an EC2 instance profile containing the IAM role to the EC2 instance.
This makes the temporary credentials available to any applications or SDKs running on the EC2 instance via the instance metadata service.

Key Concept

Securing Amazon EC2 applications using IAM roles and instance profiles.
Estimated Time:1m 0s
Rate this question