DVA-C02 · Question #109
A developer has written an application that runs on Amazon EC2 instances. The developer is adding functionality for the application to write objects to an Amazon S3 bucket. Which policy must the…
The correct answer is A. The IAM policy that is attached to the EC2 instance profile role. EC2 instances access AWS services through an IAM role attached via an instance profile; the permissions policy on that role must include the s3:PutObject action for the target bucket.
Question
A developer has written an application that runs on Amazon EC2 instances. The developer is adding functionality for the application to write objects to an Amazon S3 bucket. Which policy must the developer modify to allow the instances to write these objects?
Options
- AThe IAM policy that is attached to the EC2 instance profile role
- BThe session policy that is applied to the EC2 instance role session
- CThe AWS Key Management Service (AWS KMS) key policy that is attached to the EC2 instance
- DThe Amazon VPC endpoint policy
How the community answered
(66 responses)- A92% (61)
- B2% (1)
- C3% (2)
- D3% (2)
Why each option
EC2 instances access AWS services through an IAM role attached via an instance profile; the permissions policy on that role must include the s3:PutObject action for the target bucket.
An EC2 instance profile associates an IAM role with the instance, and the AWS SDK automatically retrieves temporary credentials from the instance metadata service. Granting the s3:PutObject (and optionally s3:PutObjectAcl) permission in the identity-based policy attached to that role is the standard and correct mechanism for allowing EC2 instances to write objects to S3.
Session policies are inline policies passed during role assumption using AWS STS; they can only restrict permissions already granted by the role's identity-based policy, not grant new ones.
A KMS key policy controls who can use or manage a specific encryption key; it does not grant S3 bucket access or the ability to write objects.
A VPC endpoint policy controls which principals and actions are permitted through the VPC endpoint; it supplements but does not replace the IAM permissions required on the instance role.
Concept tested: EC2 instance profile IAM role for S3 access
Source: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html
Community Discussion
No community discussion yet for this question.