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 to green 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 (or v1/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

image

image 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

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.

Edited by 🤖 GitLab Bot 🤖