Soru

Zorluk: KolayIAM Policies and Roles

A developer is deploying an application on a standalone Amazon EC2 instance. The application needs to read messages from an Amazon SQS queue and write records to an Amazon DynamoDB table. To follow security best practices, the developer decides to use an IAM role. Which TWO configurations or steps are required to securely grant the EC2 instance the necessary permissions? (Select TWO.)

  1. Create an IAM role with a trust policy that allows the ec2.amazonaws.com service principal to assume the role.Cevap
  2. Associate the IAM role with an EC2 instance profile and attach the instance profile to the EC2 instance.Cevap
  3. C
    Store an IAM user's long-term Access Key ID and Secret Access Key in the application's configuration file on the instance.
  4. D
    Configure the trust policy of the IAM role to allow the dynamodb.amazonaws.com service principal to assume the role.
  5. E
    Assign the application's permission policy directly to the ECS Task Execution Role of the instance.

Cevap

To securely grant the EC2 instance permissions, the developer must create an IAM role with a trust policy allowing the EC2 service principal to assume it, and attach this role to the EC2 instance using an EC2 instance profile.
The correct configurations are to create an IAM role with a trust policy that allows the EC2 service principal (ec2.amazonaws.com) to assume the role, and to associate this role with an EC2 instance profile which is then attached to the EC2 instance. This configuration allows the application running on the EC2 instance to securely retrieve temporary security credentials from the instance metadata without hardcoding secrets.

Adım Adım Çözüm

1
Determine the service principal that needs to assume the role.
Since the application runs on an EC2 instance, the trust policy must specify 'ec2.amazonaws.com' as the principal.
The trust policy controls which AWS service or entity is allowed to assume the IAM role and retrieve temporary credentials.
2
Determine how the role is associated with the EC2 instance.
The IAM role must be associated with an EC2 instance profile, and that instance profile must be attached to the EC2 instance.
EC2 instances require an instance profile to act as a bridge to attach an IAM role to the instance.

Anahtar Kavram

Assigning IAM permissions to EC2 instances using Instance Profiles and Trust Policies
Bu soruyu puanla