A developer is configuring a blue/green deployment for an Amazon ECS service using AWS CodeDeploy. The developer wants to run a validation script to perform smoke tests before production traffic is routed to the new task set. The developer creates the following `appspec.yaml` file:
yaml
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: "arn:aws:ecs:us-east-1:123456789012:task-definition/my-app:1"
LoadBalancerInfo:
ContainerName: "my-app-container"
ContainerPort: 8080
Hooks:
- BeforeAllowTraffic:
- location: scripts/run-smoke-tests.sh
timeout: 300
During deployment, the CodeDeploy agent fails to parse the AppSpec file. How should the developer modify the AppSpec file to resolve this issue?
- Replace the BeforeAllowTraffic script block with the Amazon Resource Name (ARN) of an AWS Lambda function that executes the validation logic.Answer
- BChange the Resources section name to files and specify the destination path for the run-smoke-tests.sh script on the ECS container instances.
- CUpdate the IAM trust policy of the ECS Task Execution Role to allow the codedeploy.amazonaws.com service principal to assume the role.
- DStore the content of the validation script in AWS Systems Manager Parameter Store and reference the parameter path under the BeforeAllowTraffic hook.