A developer is using AWS CodeDeploy with a blue/green deployment strategy to update an application running on Amazon ECS with the Fargate launch type. After the new (green) task set is created and traffic is shifted to it, users immediately report errors when trying to write data. The developer discovers that the green task set is connecting to a different database than the blue task set. The database endpoints are configured in the ECS task definition. What is the simplest way to prevent this issue in future deployments?
Trap 1: Create two separate Amazon RDS databases and use an Amazon Route 53…
This adds complexity and cost. It also means each task set writes to a different database, which is not the desired outcome.
Trap 2: Use an Application Load Balancer (ALB) with stickiness to route…
Stickiness doesn't solve the underlying database connection problem; it only keeps a user on the same task set during a session.
Trap 3: Use AWS CloudFormation to create a new database stack for each…
This is overly complex and unnecessary. The goal is to use the same database, not create a new one for each deployment.
- A
Modify the blue/green deployment configuration to use the same database endpoint for both task sets by updating the environment variables in the task definition before deployment.
Environment variables in the task definition can be changed without modifying the container image. Set the database endpoint to the same value for both blue and green task sets. This is the simplest solution.
- B
Create two separate Amazon RDS databases and use an Amazon Route 53 weighted routing policy to distribute traffic.
Why wrong: This adds complexity and cost. It also means each task set writes to a different database, which is not the desired outcome.
- C
Use an Application Load Balancer (ALB) with stickiness to route each user to the correct task set.
Why wrong: Stickiness doesn't solve the underlying database connection problem; it only keeps a user on the same task set during a session.
- D
Use AWS CloudFormation to create a new database stack for each deployment and update the task definition dynamically.
Why wrong: This is overly complex and unnecessary. The goal is to use the same database, not create a new one for each deployment.