Question

Difficulty: HardAWS CodeDeploy

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.)

  1. 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
  2. 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
  3. C
    Specify a BeforeInstall hook in the hooks section with a location property pointing to a script in the deployment package to run the database migration.
  4. D
    Specify an ApplicationStart hook in the hooks section that references the Amazon Resource Name (ARN) of an AWS Lambda function to run the database migration.
  5. E
    Update 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

1
Analyze the compute platform and deployment type for the CodeDeploy configuration.
The target compute platform is Amazon ECS, and the deployment type is blue/green.
ECS deployments have a different set of lifecycle hooks compared to EC2/On-Premises, and hooks must target AWS Lambda functions rather than local scripts.
2
Determine the correct hook for running database migrations before task set creation.
The BeforeInstall hook is selected.
BeforeInstall runs before CodeDeploy creates the replacement task set, which is the correct time to run database schema migrations.
3
Determine the correct hook for running integration tests via the test port after test traffic routing.
The AfterAllowTestTraffic hook is selected.
AfterAllowTestTraffic runs after test traffic is shifted to the replacement task set, allowing validation of the application before production traffic is routed.

Key Concept

AWS CodeDeploy ECS Lifecycle Hooks
Rate this question