A SysOps administrator is configuring an Amazon EC2 Image Builder pipeline in Account A () to build custom machine images. The pipeline is configured to run using an IAM role named `ImageBuilderPipelineExecutionRole`. During the build process, the pipeline launches an EC2 instance that must run with an IAM instance profile associated with the IAM role `ImageBuilderBuildRole`. When the pipeline is executed, it fails during the build phase with an Access Denied error when attempting to launch the EC2 build instance. The `ImageBuilderPipelineExecutionRole` permissions policy contains permissions for `imagebuilder:*` and `ec2:*` actions but does not contain any other permissions. Which modification to the IAM policies will resolve this error?
- AAdd `sts:AssumeRole` permissions for the `ImageBuilderBuildRole` resource to the `ImageBuilderPipelineExecutionRole` permissions policy.
- BModify the trust policy of `ImageBuilderBuildRole` to allow the `ImageBuilderPipelineExecutionRole` to perform the `sts:AssumeRole` action.
- Add `iam:PassRole` permissions for the `ImageBuilderBuildRole` resource to the `ImageBuilderPipelineExecutionRole` permissions policy.Answer
- DAttach a policy to `ImageBuilderBuildRole` allowing it to perform the `sts:AssumeRole` action on the `ImageBuilderPipelineExecutionRole` resource.
Answer
Add `iam:PassRole` permissions for the `ImageBuilderBuildRole` resource to the `ImageBuilderPipelineExecutionRole` permissions policy.
To launch an Amazon EC2 instance with an IAM role associated, the principal launching the instance (in this case, the EC2 Image Builder pipeline execution role) must have `iam:PassRole` permissions on the role being passed to the instance (`ImageBuilderBuildRole`). This allows the pipeline to safely delegate the role to the EC2 service for the build instance.
Step-by-Step Solution
Key Concept
IAM Role Delegation and the PassRole Permission
Estimated Time:2m 0s