Creating a blue/green deployment - Amazon Aurora

Creating a blue/green deployment

When you create a blue/green deployment, you specify the DB cluster to copy in the deployment. The DB cluster you choose is the production DB cluster, and it becomes the DB cluster in the blue environment. RDS copies the blue environment's topology to a staging area, along with its configured features. The DB cluster is copied to the green environment, and RDS configures replication from the DB cluster in the blue environment to the DB cluster in the green environment. RDS also copies all of the DB instances in the DB cluster.

Preparing for a blue/green deployment

There are certain steps you must take before you create a blue/green deployment, depending on the engine that your Aurora DB cluster is running.

Preparing an Aurora MySQL cluster for a blue/green deployment

Before you create a blue/green deployment for an Aurora MySQL DB cluster, the cluster must be associated with a custom DB cluster parameter group with binary logging (binlog_format) turned on. Binary logging is required for replication from the blue environment to the green environment. While any binlog format works, we recommend ROW to reduce the risk of replication inconsistencies. For information about creating a custom DB cluster parameter group and setting parameters, see Working with DB cluster parameter groups.

Note

Enabling binary logging increases the number of write disk I/O operations to the DB cluster. You can monitor IOPS usage with the VolumeWriteIOPs CloudWatch metric.

After you enable binary logging, make sure to reboot the DB cluster so that your changes take effect. Blue/green deployments require that the writer instance be in sync with the DB cluster parameter group, otherwise creation fails. For more information, see Rebooting a DB instance within an Aurora cluster.

Preparing an Aurora PostgreSQL cluster for a blue/green deployment

Before you create a blue/green deployment for an Aurora PostgreSQL DB cluster, make sure to do the following:

  • Associate the cluster with a custom DB cluster parameter group that has logical replication (rds.logical_replication) enabled. Logical replication is required for replication from the blue environment to the green environment.

    When you enable logical replication, you also need to tune certain cluster parameters, such as max_replication_slots, max_logical_replication_workers, and max_worker_processes. For instructions to enable logical replication and tune these parameters, see Setting up logical replication for your Aurora PostgreSQL DB cluster.

    In addition, make sure that the synchronous_commit parameter is set to on.

    After you configure the required parameters, make sure to reboot the DB cluster so that your changes take effect. Blue/green deployments require that the writer instance be in sync with the DB cluster parameter group, otherwise creation fails. For more information, see Rebooting a DB instance within an Aurora cluster.

  • Make sure that your DB cluster is running a version of Aurora PostgreSQL that's compatible with Blue/Green Deployments. For a list of compatible versions, see Blue/Green Deployments with Aurora PostgreSQL.

  • Make sure that all tables in the DB cluster have a primary key. PostgreSQL logical replication doesn't allow UPDATE or DELETE operations on tables that don't have a primary key.

Specifying changes when creating a blue/green deployment

You can make the following changes to the DB cluster in the green environment when you create the blue/green deployment.

You can make other modifications to the DB cluster and its DB instances in the green environment after it is deployed. For example, you might make schema changes to your database.

For information about modifying a DB cluster, see Modifying an Amazon Aurora DB cluster.

Specify a higher engine version

You can specify a higher engine version if you want to test a DB engine upgrade. Upon switchover, the database is upgraded to the major or minor DB engine version that you specify.

Specify a different DB parameter group

Specify a DB cluster parameter group that is different from the one used by the DB cluster. You can test how parameter changes affect the DB cluster in the green environment or specify a parameter group for a new major DB engine version in the case of an upgrade.

If you specify a different DB cluster parameter group, the specified parameter group is associated with the DB cluster in the green environment. If you don't specify a different DB cluster parameter group, the DB cluster in the green environment is associated with the same parameter group as the blue DB cluster.

Creating a blue/green deployment

You can create a blue/green deployment using the AWS Management Console, the AWS CLI, or the RDS API.

To create a blue/green deployment
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB cluster that you want to copy to a green environment.

  3. Choose Actions, Create Blue/Green Deployment.

    If you choose an Aurora PostgreSQL DB cluster, review and acknowledge the logical replication limitations. For more information, see PostgreSQL logical replication limitations for blue/green deployments.

    The Create Blue/Green Deployment page appears.

    
                  Create blue/green deployment
  4. Review the blue database identifiers. Make sure that they match the DB instances that you expect in the blue environment. If they don't, choose Cancel.

  5. For Blue/Green Deployment identifier, enter a name for your blue/green deployment.

  6. (Optional) For Blue/Green Deployment settings, specify the settings for the green environment:

    • Choose a DB engine version if you want to test a DB engine version upgrade.

    • Choose a DB cluster parameter group to associate with the DB cluster in the green environment.

    • Choose a DB parameter group to associate with the DB instances in the green environment.

    You can make other modifications to the databases in the green environment after it is deployed.

  7. Choose Create staging environment.

To create a blue/green deployment using the AWS CLI, use the create-blue-green-deployment command with the following options:

  • --blue-green-deployment-name – Specify the name of the blue/green deployment.

  • --source – Specify the ARN of the DB cluster that you want to copy.

  • --target-engine-version – Specify an engine version if you want to test a DB engine version upgrade in the green environment. This option upgrades the DB cluster in the green environment to the specified DB engine version.

    If not specified, the DB cluster in the green environment is created with the same engine version as DB cluster in the blue environment.

  • --target-db-cluster-parameter-group-name – Specify a DB cluster parameter group to associate with the DB cluster in the green environment.

  • --target-db-parameter-group-name – Specify a DB parameter group to associate with the DB instances in the green environment.

Example Create a blue/green deployment

For Linux, macOS, or Unix:

aws rds create-blue-green-deployment \ --blue-green-deployment-name aurora-blue-green-deployment \ --source arn:aws:rds:us-east-2:123456789012:cluster:auroradb \ --target-engine-version 8.0 \ --target-db-cluster-parameter-group-name mydbclusterparametergroup

For Windows:

aws rds create-blue-green-deployment ^ --blue-green-deployment-name aurora-blue-green-deployment ^ --source arn:aws:rds:us-east-2:123456789012:cluster:auroradb ^ --target-engine-version 8.0 ^ --target-db-cluster-parameter-group-name mydbclusterparametergroup

To create a blue/green deployment by using the Amazon RDS API, use the CreateBlueGreenDeployment operation with the following parameters:

  • BlueGreenDeploymentName – Specify the name of the blue/green deployment.

  • Source – Specify the ARN of the DB cluster that you want to copy to the green environment.

  • TargetEngineVersion – Specify an engine version if you want to test a DB engine version upgrade in the green environment. This option upgrades the DB cluster in the green environment to the specified DB engine version.

    If not specified, the DB cluster in the green environment is created with the same engine version as DB cluster in the blue environment.

  • TargetDBClusterParameterGroupName – Specify a DB cluster parameter group to associate with the DB cluster in the green environment.

  • TargetDBParameterGroupName – Specify a DB parameter group to associate with the DB instances in the green environment.