Blue/Green Deployments in Amazon Aurora and Amazon RDS. How it Looks?
Tags: aws, rds, tutorial, news
Published: 2022-11-29 01:51:14

Today AWS announced Blue/Green Deployment in Amazon Aurora and Amazon RDS; I decided to explore it a bit.

Mind you! the deployment is unavailable for all the database engines supported by RDS. Amazon RDS Blue/Green Deployments is available today on Amazon Aurora with MySQL Compatibility 5.6 or higher, Amazon RDS for MySQL major version 5.6 or higher, and Amazon RDS for MariaDB 10.2 and higher.

I would suggest, refer AWS documentation for the latest version support information [Here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RDS_Fea_Regions_DB-eng.Feature.BlueGreenDeployments.html).

Let's see how to set up and use the deployment option.

<u>Current Aurora MYSQL cluster -
</u>
Used Dev/Test cluster, didn't use production cluster for the exercise. No points guessing why I chose so. The good thing is that the Blue/Green deployment is not restricted to the production systems alone.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18v49prtvrry6cnpp9aq.png)

To use a Blue/Green Deployment in your Aurora MySQL DB cluster, you should turn on binary logging, changing the value for the binlog_format parameter from OFF to MIXED in the DB cluster parameter group.

If binlog_format is OFF, you can expect this error message while creating Blue/Green deployment.

![Error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tshjanba03oh6o0vaol.png)

If using default cluster parameter group, then create new cluster parameter group with binlog_format parameter value as MIXED and change your Aurora MySQL cluster parameter group to new one.

[turn on binary logging](https://aws.amazon.com/premiumsupport/knowledge-center/enable-binary-logging-aurora/)

Select the database that needs to be updated in the console and click Create Blue/Green Deployment under the Actions dropdown menu.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6f8rureyybc6a716rno.png)

Provide 'Blue/Green Deployment Identifier' and chose current DB version itself.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhwbbkumezg6nu3hzuc4.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du2p59luiagfqvvh4nna.png)

Click 'Create Staging Environment'.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibhovaqlc8bz6zcu0bqy.png)

Oops..got this error

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2902v6ttk7yv65c300zc.png)

Have changed Cluster parameter group but haven't rebooted primary database. 

After you change the DB cluster parameter group associated with a DB cluster, reboot the primary DB instance in the cluster to apply the changes to all of the DB instances in the cluster.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec29qn83017t6gjmg8ax.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0eifaqbtigetm6bkyxo.png)

Let's try to create blue/green deployment again. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lasmog1mo0da1zf414q.png)

Notice existing cluster changed to **Blue** and new one is created as **Green**.

![Blue Green Deployment Ready](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2skd8556jx71txd4eazv.png)

Now you are nearly ready to switch over your green databases to production. Check the settings of your green databases to verify that they are ready for the switchover. You may also set a timeout setting to determine the maximum time limit for your switchover. If Blue/Green Deployments’ switchover guardrails detect that it would take longer than the specified duration, then the switchover is canceled, and no changes are made to the environments.

Choose deployment name where role is "Blue/Green Deployment". Green field will have the same setup as of original configuration in terms of writer, reader, replicas or Multi-AZ database.

![Switchover Action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cuxye1nndzfuge7hxka.png)

![Pre-Switchover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qwbb7asierpfl9aaq4ym.png)

![Pre-Switchover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23jnx9piy4ptsctow7jt.png)

Default timeout was 5 minutes and I changed it to 15 just incase as trying this option the first time. Then click switchover.

![Pre-Switchover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6lg1fojwwdglmszseup8.png)

![RDS is Switching over](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/572r2g7dbqdis2dyf60m.png)

![Switching over](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8c6wf4bi8zh9v9ff3bv.png)

RDS Page gone unresponsive for a bit -

![Page unresponsive](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj0h4mhso29mpac0ge39.png)

Reloaded webpage and hurrey, Switchover Completed !!!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iktoeio443oay3pkw8by.png)

Look at the Blue/Green Deployment details -

![Switchover Completed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1ruzgisggwqyqupbcud.png)

After switchover, Blue/Green Deployments does not delete your old production environment. You may access it for additional validations and performance/regression testing, if needed. 
You should remove old environment manually to avoid incurring charges.

![Delete old database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puglenvahnzbnu6tktjh.png)

![Delete old database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7j11xqmdpsctqcpz50pb.png)

![Delete old database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtra9dyi57hvm71tbzku.png)

All done !!

![Final Look](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bke2kwprshlq0k7hpym5.png)

Blue/Green Deployment for Amazon Aurora and Amazon RDS looks to be a great feature. The further testing is warranted, specially when Green field is not exactly the same as Blue i.e. what if database version is higher than original or some other changes. Let's try few more scenarios....next time !!

If you are a fan of video content then please watch blue/green deployment in action here -

{% embed https://youtu.be/o5pOjNNexWU %}

P.S. [AWS Announcement for your quick reference](https://aws.amazon.com/blogs/aws/new-fully-managed-blue-green-deployments-in-amazon-aurora-and-amazon-rds/
)