A developer is configuring AWS CodeDeploy to perform in-place deployments of a web application to a fleet of Amazon EC2 instances. The deployment group is configured, but the deployments fail immediately at the start with an error indicating that CodeDeploy does not have permission to access the target instances. The developer needs to ensure that the CodeDeploy service has the necessary permissions to perform the deployment.
Which configuration change will resolve this issue?
- AAdd ECS-specific lifecycle hooks such as BeforeAllowTraffic and AfterAllowTraffic to the appspec.yml file to allow traffic routing.
- Update the trust policy of the CodeDeploy IAM service role to allow the codedeploy.amazonaws.com service principal to assume the role.Answer
- CUpdate the trust policy of the EC2 instance profile role to allow the ec2.amazonaws.com service principal to assume the role.
- DStore the CodeDeploy service role credentials as a secure string in AWS Systems Manager Parameter Store and retrieve them using an instance bootstrap script.
Answer
Updating the trust policy of the CodeDeploy IAM service role to trust the CodeDeploy service principal.
Updating the trust policy of the CodeDeploy IAM service role to allow the codedeploy.amazonaws.com service principal to assume the role is correct. CodeDeploy requires a service role with permissions to access EC2 instances and ECS services on your behalf, and this role must trust the CodeDeploy service principal so that AWS CodeDeploy can assume it using AWS Security Token Service (STS).
Step-by-Step Solution
Key Concept
IAM service roles and trust policies for AWS CodeDeploy
Estimated Time:2m 0s