A developer is configuring a deployment pipeline in AWS CodePipeline to deploy a serverless application across two AWS accounts. The pipeline resides in Account A, and the application must be deployed to Account B using an AWS CloudFormation action in the deploy stage. The pipeline execution fails at the deploy stage with an access denied error when attempting to assume the deployment IAM role created in Account B.
How should the developer configure the IAM policies to successfully allow the pipeline in Account A to assume the deployment role in Account B?
- Configure the trust policy of the deployment role in Account B to allow the sts:AssumeRole action from the CodePipeline service role in Account A, and grant the CodePipeline service role in Account A permission to call sts:AssumeRole on the deployment role in Account B.Cevap
- BAttach an identity-based IAM policy to the CodePipeline service role in Account A that allows the sts:AssumeRole action on the deployment role in Account B, as cross-account permissions do not require trust policies when initiated from a managed pipeline service role.
- CCreate an IAM user in Account B, generate long-lived access keys, and store them as a secure parameter in AWS Systems Manager Parameter Store with automatic rotation configured, then reference the parameter in the pipeline configuration.
- DAdd an aws sts assume-role command to the buildspec.yml file in the source repository to authenticate as Account B, and configure the CloudFormation deployment action to execute using the resulting temporary credentials.
Cevap
Configure the trust policy of the deployment role in Account B to allow the sts:AssumeRole action from the CodePipeline service role in Account A, and grant the CodePipeline service role in Account A permission to call sts:AssumeRole on the deployment role in Account B.
The correct option correctly establishes two-way trust for cross-account role assumption. The trust policy of the target role in Account B must trust the CodePipeline service role in Account A, and the CodePipeline service role must have an identity-based policy allowing it to assume the target role in Account B.
Adım Adım Çözüm
Anahtar Kavram
Cross-account role assumption in AWS CodePipeline