Soru

Zorluk: KolayIAM Policies and Roles

A developer is configuring an application running on an Amazon EC2 instance that needs to read items from an Amazon DynamoDB table. The developer has created the following trust policy for an IAM role:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}

Which TWO steps must the developer complete to enable the application on the EC2 instance to securely access the DynamoDB table without hardcoding credentials?

  1. Attach a permissions policy to the IAM role that grants the necessary DynamoDB permissions (such as dynamodb:GetItem).Cevap
  2. Associate the IAM role with an IAM instance profile and attach the instance profile to the EC2 instance.Cevap
  3. C
    Embed IAM user access keys with DynamoDB permissions directly in the application's configuration files.
  4. D
    Change the service principal in the trust policy to dynamodb.amazonaws.com so the database can access the instance.
  5. E
    Attach the IAM permissions policy directly to the EC2 instance's security group using the AWS Management Console.

Cevap

To securely grant access, the developer must attach a permissions policy with DynamoDB access to the IAM role, and then associate the IAM role with an IAM instance profile and attach it to the EC2 instance.
The correct steps are to attach a permissions policy containing the required DynamoDB permissions to the IAM role, and to associate the role with an IAM instance profile and attach it to the EC2 instance. This combination allows the application on the EC2 instance to assume the role and gain the necessary permissions to read DynamoDB data securely.

Adım Adım Çözüm

1
Analyze the trust policy.
The trust policy currently allows the Amazon EC2 service principal to assume the IAM role.
This establishes the trust relationship allowing EC2 instances to use the role.
2
Define and attach the permissions policy.
Create an IAM policy that grants DynamoDB permissions and attach it to the IAM role.
An IAM role must have a permissions policy to define what actions are allowed on resources.
3
Associate the role with the EC2 instance.
Create an IAM instance profile, associate the role with it, and attach the instance profile to the EC2 instance.
EC2 instances cannot assume IAM roles directly; they must do so via an IAM instance profile.

Anahtar Kavram

Granting EC2 instances permissions to access AWS services using IAM roles and instance profiles.
Tahmini Süre:1m 30s
Bu soruyu puanla