Blue/Green Deployments for AWS ECS
Problem to solve
As a developer deploying to AWS ECS, I want to deploy using blue/green deployment method.
Intended users
User experience goal
The user should be able to switch between blue/green environments directly from GitLab and be able to visually see both environments and know which production is currently being used by the users.
Proposal
Leverage existing AWS infrastructure to accomplish this
Assumptions:
- 2 target groups exist in the EC2 console - blue and green (can be created via AWS console or API).
- The target groups are configured to the autoscaling groups.
- There is a deployment group configured
- There is a listener rule - forward to
blue
/forward togreen
created for each of the target groups
We need to add support to:
- Build and push blue/green container images to the GitLab's package repository
- Tag the images
blue/green
(orv1/v2
) - ECS service for blue/green deployments
Option one - use forwarding rules:
- Change the listener forwarding rule using the
modify-rule
API
When a user presses the Changes the weights of the deployments - the listener rule should be updated to the other environment
- blue->green
- green->blue
When the user uses quick action /switch
the listener rule should be updated
Option two: -Swap the container images
- Update Task Definition revision using green container image
- Replace the Image with the secondary image (v2) URI
- Update ECS service to use new Task Definition revision and trigger a new deployment
The user needs to know which environment/URL is currently blue and which is green
Further details
forward
Forward requests to the specified target groups. For more information, see Forward actions.
modify-rule
Description Replaces the specified properties of the specified rule. Any properties that you do not specify are unchanged.
To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.
modify-rule
--rule-arn <value>
[--conditions <value>]
[--actions <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
Permissions and Security
Only users who have permission to deploy to production can switch environments
Documentation
Availability & Testing
What does success look like, and how can we measure that?
What is the type of buyer?
Is this a cross-stage feature?
Links / references
- https://aws.amazon.com/blogs/containers/aws-codedeploy-now-supports-linear-and-canary-deployments-for-amazon-ecs/
- https://aws.amazon.com/blogs/aws/new-application-load-balancer-simplifies-deployment-with-weighted-target-groups/
- https://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment-group.html
- https://github.com/aws-samples/aws-codedeploy-linear-canary-deployments-blog
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.