A developer is setting up AWS CodeDeploy to deploy an application to Amazon EC2 instances. The deployment fails because CodeDeploy lacks the necessary permissions to interact with AWS services on behalf of the developer.
Which configuration must the developer implement to resolve this permission issue?
- Create an IAM service role for CodeDeploy and configure its trust policy to allow the codedeploy.amazonaws.com service to assume the role.Answer
- BCreate an IAM role for the EC2 instances and attach a policy allowing the codedeploy:AssumeRole action directly on the instances.
- CStore the AWS credentials for CodeDeploy in AWS Systems Manager Parameter Store and retrieve them using an EC2 user data script.
- DConfigure the AppSpec file with the EC2-specific ApplicationStart hook to execute a script that elevates CodeDeploy agent permissions.
Answer
Create an IAM service role for CodeDeploy and configure its trust policy to allow the codedeploy.amazonaws.com service to assume the role.
The correct answer is to create an IAM service role for CodeDeploy with a trust policy that allows the codedeploy.amazonaws.com service principal to assume the role. This permits CodeDeploy to perform necessary operations, such as interacting with EC2 instances, on the developer's behalf.
Step-by-Step Solution
Key Concept
AWS CodeDeploy Service Role configuration and trust policy requirements