A developer is configuring a blue/green deployment for a containerized microservice running on Amazon ECS using AWS CodeDeploy. The deployment must execute a database schema migration before the replacement task set is created. Additionally, after the replacement task set is provisioned and test traffic is routed to it via a test listener, the developer must run integration tests against the test port to validate the deployment before shifting production traffic.
Which of the following configurations should the developer implement in the AppSpec file to meet these requirements? (Select TWO.)
- Specify a BeforeInstall hook in the hooks section that references the Amazon Resource Name (ARN) of an AWS Lambda function designed to run the database migrations.Answer
- Specify an AfterAllowTestTraffic hook in the hooks section that references the Amazon Resource Name (ARN) of an AWS Lambda function designed to run the integration tests against the test port.Answer
- CSpecify a BeforeInstall hook in the hooks section with a location property pointing to a script in the deployment package to run the database migration.
- DSpecify an ApplicationStart hook in the hooks section that references the Amazon Resource Name (ARN) of an AWS Lambda function to run the database migration.
- EUpdate the trust policy of the ECS task execution role to allow codedeploy.amazonaws.com to assume the role, and reference the role ARN directly under the BeforeInstall hook.
Answer
Specify a BeforeInstall hook in the hooks section referencing the ARN of a Lambda function to run the database migrations, and specify an AfterAllowTestTraffic hook referencing the ARN of a Lambda function to run the integration tests against the test port.
For an Amazon ECS deployment, CodeDeploy lifecycle hooks must reference AWS Lambda functions. The BeforeInstall hook runs before the replacement task set is created, which is the correct time to run database schema migrations. The AfterAllowTestTraffic hook runs after test traffic is routed to the new task set, which is the correct phase to validate the application via the test port before production traffic is shifted.
Step-by-Step Solution
Key Concept
AWS CodeDeploy ECS Lifecycle Hooks