SCS-C02 · Question #56
A security engineer is trying to use Amazon EC2 Image Builder to create an image of an EC2 instance. The security engineer has configured the pipeline to send logs to an Amazon S3 bucket. When the…
The correct answer is B. Ensure that the following policies are attached to the instance profile for the EC2 instance: E. Ensure that the instance profile for the EC2 instance has the s3:PutObject permission for the S3. The 403 error occurs because the EC2 instance profile lacks the necessary permissions to write logs to S3 and to use Image Builder; the instance profile, not the engineer's role, performs the build actions.
Question
A security engineer is trying to use Amazon EC2 Image Builder to create an image of an EC2 instance. The security engineer has configured the pipeline to send logs to an Amazon S3 bucket. When the security engineer runs the pipeline, the build fails with the following error:
"AccessDenied: Access Denied status code: 403". The security engineer must resolve the error by implementing a solution that complies with best practices for least privilege access. Which combination of steps will meet these requirements? (Choose two.)
Options
- AEnsure that the following policies are attached to the IAM role that the security engineer is using:
- BEnsure that the following policies are attached to the instance profile for the EC2 instance:
- CEnsure that the AWSImageBuilderFullAccess policy is attached to the instance profile for the EC2
- DEnsure that the security engineer's IAM role has the s3:PutObject permission for the S3 bucket.
- EEnsure that the instance profile for the EC2 instance has the s3:PutObject permission for the S3
How the community answered
(45 responses)- A4% (2)
- B73% (33)
- C16% (7)
- D7% (3)
Why each option
The 403 error occurs because the EC2 instance profile lacks the necessary permissions to write logs to S3 and to use Image Builder; the instance profile, not the engineer's role, performs the build actions.
The security engineer's own IAM role is used to initiate and configure the pipeline, not to execute it. The 403 error during the build phase originates from the EC2 instance's instance profile, so adding policies to the engineer's role does not resolve the build-time access denial.
EC2 Image Builder pipelines run on EC2 instances that operate under an instance profile. The instance profile must have the EC2InstanceProfileForImageBuilder and EC2InstanceProfileForImageBuilderECRContainerBuilds managed policies attached so that the instance can communicate with the Image Builder service and perform build operations.
Attaching AWSImageBuilderFullAccess to the instance profile grants far broader permissions than necessary for a build instance, violating the principle of least privilege. The managed policies in option B provide the appropriate scoped permissions.
Granting s3:PutObject to the security engineer's IAM role does not help because the engineer's role is not the principal writing logs during the build. The EC2 instance uses its instance profile credentials for all actions performed during pipeline execution.
The build instance itself (not the security engineer's IAM user) writes logs to S3 during the pipeline run. Granting the instance profile's IAM role the s3:PutObject permission on the target S3 bucket is the least-privilege fix that allows log delivery while limiting access to only what is required.
Concept tested: EC2 Image Builder instance profile permissions and least privilege
Source: https://docs.aws.amazon.com/imagebuilder/latest/userguide/image-builder-setting-up.html
Topics
Community Discussion
No community discussion yet for this question.