You are on page 1of 11

AWS RDS

Blue/Green
Deployment
For Database Updates
A how to example to Automate AWS RDS
Database Version Upgrade
When a blue/green deployment is created, one specifies the source DB instance to copy in the
deployment. The DB instance choosed is the production DB instance, and it becomes the primary DB
instance in the blue environment. This DB instance is copied to the green environment, and RDS
configures replication from the DB instance in the blue environment to the DB instance in the green
environment.

In this howto, the AWS RDS MySQL database will be upgraded from 8.0.33 to 8.0.34

The Source AWS RDS db (assuming production database) should be enabled backups.

Currently Blue/Green Deployments are supported only for RDS for MariaDB, RDS for MySQL, and RDS
for PostgreSQL. (Please check also for in region availability). This howto only applies to AWS RDS not
Aurora.
Note: Please read and understand the official documentation to perform this exercise in Production

Let us begin:

First check the current version of database


aws rds describe-db-instances \
--db-instance-identifier dxb-mysql8e
--query
DBInstances[]."{Version:EngineVersion,ConnectionStr:Endpoint.Address
}"

The current version is 8.0.33, now will check Valid Upgrade Target Engine Version that we can
upgrade.

aws rds describe-db-engine-versions \


--engine mysql \
--engine-version 8.0.33 \
--query DBEngineVersions[].ValidUpgradeTarget[].EngineVersion

The db can be upgraded to those version butr requirement is to upgrade to MySQL 8.0.34.

From AWS console browse to RDS select current db and click on configuration tab
Both current version and option group can be found as option group will be needed for Blue/Green
deployments.

Login to db and create sample database if you there is not one.

Create some tables if you not alrady in accounts database


source db_backup.sql
For creating blue/green rds deployment source ARN and optiongroup is required plus the new
database version to upgrade, here in this case it is 8.0.34

aws rds create-blue-green-deployment \


--blue-green-deployment-name rds-blue-green-deployment \
--source arn:aws:rds:me-central-1:192384637041:db:dxb-mysql8e \
--target-engine-version 8.0.34 \
--target-db-parameter-group-name mysql8secgrp

This will retun blue/green deployment identifier and status, the identifier will be used from cli to check
progress of deployment.
blue-green-deployment-identifier bgd-v53303651eexfake
aws rds describe-blue-green-deployments \
--blue-green-deployment-identifier bgd-v53303651eexfake

A new read replica of source is being created , once created the replication under the hood is
established.
Check status :
aws rds describe-blue-green-deployments \
--blue-green-deployment-identifier bgd-v53303651eexfake
Replica is sucessfully completed and Upgrade is in progress.

Now replica of database is successfully complete


Now we have two databases with 2 connection endpoints

Blue: dxb-mysql8e.cr10kl5snwf2.me-central-1.rds.amazonaws.com
Green: dxb-mysql8e-green-r43j0a.cr10kl5snwf2.me-central-1.rds.amazonaws.com

Connection will be made to both and check the EngineVersion:

Blue:
Green:

Now that new Green has the desired EngineVersion 8.0.34, switchover timeout period can be
specified between 30 seconds and 3,600 seconds (one hour). If the switchover takes longer than the
specified duration, then any changes are rolled back and no changes are made to either
environment. The default timeout period is 300 seconds (five minutes).

aws rds switchover-blue-green-deployment \


--blue-green-deployment-identifier bgd-yd4hjmjekfw5zt7y \
--switchover-timeout 300
Switchover completed (note the blue is appended with old1)

Check Blue:
Blue : dxb-mysql8e.cr10kl5snwf2.me-central-1.rds.amazonaws.com

mysql -u admin -h dxb-mysql8e.cr10kl5snwf2.me-central-1.rds.amazonaws.com -


p'Mysecret23'

Confirm that EngineVersion is upgraded to 8.0.34


Once confirmed and everything is working, proceed to delete deployment and delete old database .
aws rds delete-blue-green-deployment \
--blue-green-deployment-identifier bgd-yd4hjmjekfw5zt7y \
--no-delete-target

You might also like