How do you implement Blue/Green deployment in AWS (Part 1/7)
In this 7-parts tutorial, we will create an initial environment composed of an autoscaling group with two ubuntu machines behind a load balancer, then we will create a CI/CD pipeline to provide blue/green deployments using CodeBuild, CodeDeploy, and CodePipeline.
How often do your users experience downtime, caused by a buggy release? How often do you have to stay up late to take down a system? Do release days make you feel anxious?
Well, it doesn’t have to be that way. We’re here to help you make safe deployments without downtime.
In this tutorial:
- Prerequisites
- Setup the initial environment
- Configure CodeBuild
- Configure CodeDeploy
- Configure CodePipeline
- Putting all together
The benefits of blue/green deployments
Blue/green deployment involves two production environments:
- Blue is the active environment.
- Green is for the release of a new version.
Here are some of the advantages of a blue/green deployment:
- You can perform testing on the green environment without disrupting the blue environment.
- Switching to the green environment involves no downtime. It only requires the redirecting of user traffic.
- Rolling back from the green environment to the blue environment in the event of a problem is easier because you can redirect traffic to the blue environment without having to rebuild it.
- You can incorporate the principle of infrastructure immutability by provisioning fresh instances when you need to make changes. In this way, you avoid configuration drift.
AWS CodeDeploy offers two ways to perform blue/green deployments on EC2:
- In the first approach, AWS CodeDeploy makes a copy of an Auto Scaling group. It, in turn, provisions new Amazon EC2 instances, deploys the application to these new instances and then redirects traffic to the newly deployed code.
- In the second approach, you use instance tags or an Auto Scaling group to select the instances that will be used for the green environment. AWS CodeDeploy then deploys the code to the tagged instances.
References
Next: How do you implement Blue/Green deployment in AWS (Part 2/7) [Will be available soon]