Blue Green Deployments on AWS

Rajat Gupta
#FML
Published in
2 min readJul 24, 2017

Blue Green deployment is killing your old servers and replacing them with the new servers freshly provisioned. Blue refers to the old servers and green represents to the new server.

Why Blue Green Deployments?

Blue Green deployments helps in updating and managing your server OS versions as well as updating dependencies versions very easily. Suppose, if you are running servers on Ubuntu 12.04, now what happens after 5 years when you will not get any updates for the OS. If you have the capability to spawn new servers on properly tested custom AMIs, you will be able to upgrade your severs very easily and confidently.

Blue Green Deployment

On AWS, some companies may also be running docker containers on EC2 instances, which leads to the memory and system resources issues, if the servers are running for a very long time.

How can we achieve Blue Green Deployments on AWS?

To achieve Blue Green Deployment, start with the CI.

Step 1: Build Artifacts from CI

Now, here once the repository is ready for the release, you can generate the artifacts after successful CI build. These artifacts can be .zip, docker containers etc. Push these trusted artifacts to some storage service like Amazon S3 or Docker Hub.

Step 2: Generate custom AMI

Now, with the help of Packer, you can create a Base AMI of your choice and pull the artifact into this base AMI and all pre-required dependencies. Install everything and push this custom built AMI to the Amazon MarketPlace.

Now, you have a custom AMI which has your API/Service installed in it. Just spawning the instance from the custom AMI, should start your service.

Step 3: Spawn servers from custom AMI

Now, using some automation script written in Ansible or Puppet , you spawn new servers from the custom built AMI and redirect your load balancers or DNS servers to the newly created servers.

This will decrease the time of deployment and will increase the confidence of deployment on new versions etc.

--

--