AWS Certified Developer – Associate (DVA-C02)DeploymentHard

A company is using AWS CodePipeline to automate the deployment of a containerized application to Amazon ECS. They need to ensure that database schema migrations are executed successfully before the new application containers are brought online, and that a rollback mechanism is in place if the migrations fail. Which CodePipeline action type and integration would best support this requirement?

  1. AImplement a Lambda function within the CodePipeline to trigger schema migrations, followed by an ECS update service action.
  2. BUtilize a CodeDeploy action with a Blue/Green deployment strategy for ECS, configuring a pre-traffic hook for schema migrations.
  3. CAdd a CodeBuild action to run schema migrations before the ECS deployment, with a manual approval step.
  4. DAdd an SQS queue to trigger an EC2 instance to perform schema migrations, then update the ECS service through CodePipeline.
Show answer & explanation

Correct answer: B. Utilize a CodeDeploy action with a Blue/Green deployment strategy for ECS, configuring a pre-traffic hook for schema migrations.

AWS CodeDeploy with a Blue/Green deployment strategy for Amazon ECS is specifically designed to handle this scenario. The pre-traffic hook allows custom scripts (like database schema migrations) to run on the new task set before traffic is shifted. If the hook fails or an alarm is triggered, CodeDeploy can automatically roll back to the old task set, ensuring data integrity and application availability.

Why the other options are wrong

  • A. A Lambda function could run migrations, but integrating it directly with ECS updates in CodePipeline would require custom logic for rollback and health checks, which CodeDeploy Blue/Green provides out-of-the-box.
  • C. While CodeBuild can run migrations, integrating it directly before an ECS deployment in CodePipeline doesn't provide the built-in rollback mechanism and traffic shifting capabilities of CodeDeploy Blue/Green for ECS.
  • D. Using SQS and EC2 instances adds unnecessary complexity and doesn't leverage the native ECS deployment and rollback features provided by CodeDeploy.

CodeDeploy Blue/Green for ECS

A CodeDeploy deployment strategy for Amazon ECS that creates a new, identical environment (green task set), shifts traffic to it, and provides pre-traffic hooks for validation and automatic rollback capabilities.

  • Zero-downtime deployments for ECS.
  • Pre-traffic hooks for validation/migrations.
  • Automatic rollback on failure.

Memory trick: ECS Deploy: Ensure Changes Succeed.

More Deployment questions