Upgrade a CloudFormation or CDK managed Aurora Serverless v1 cluster to Aurora Serverless v2

2 minute read
Content level: Advanced
0

This article outlines the process for upgrading Aurora Serverless v1 clusters to Aurora Serverless v2 for users who manage their clusters using CloudFormation or CDK.

Overview

If you have a CloudFormation or CDK-managed Aurora Serverless v1 cluster, you can follow these steps to migrate your cluster to Aurora Serverless v2.

Process

  1. Ensure that the Aurora Serverless v1 cluster has DeletionPolicy set to Retain. To learn more about the DeletionPolicy attribute, refer to DeletionPolicy in the AWS CloudFormation documentation.
  2. Remove the Aurora Serverless v1 cluster from your CloudFormation stack and deploy it. CloudFormation will skip deletion of the cluster because of the deletion policy. If you have references to the Aurora Serverless v1 cluster, you will need to temporarily replace them with hardcoded strings
  3. Follow the steps in the “Upgrade from Amazon Aurora Serverless v1 to v2 with minimal downtime” blog post
  4. Update the stack template to match the cluster you just upgraded, including the instance. For example:
Resources:
  DBCluster:
    Type: "AWS::RDS::DBCluster"
    Properties:
      DatabaseName: database1
      Engine: aurora-mysql
      EngineMode: provisioned
      EngineVersion: 8.0.mysql_aurora.3.04.1
      MasterUsername: admin
      MasterUserPassword: 12345678
    DeletionPolicy: Retain
  DBInstance:
    Type: "AWS::RDS::DBInstance"
    Properties:
      DBClusterIdentifier: !Ref DBCluster
      DBInstanceClass: db.serverless
      Engine: aurora-mysql
    DeletionPolicy: Retain
  1. Import the cluster and instance into the stack according to “Importing existing resources into a stack” in the AWS CloudFormation documentation
  2. Detect drift on the CloudFormation stack and ensure there is none for the Aurora Serverless v2 cluster and instance. If there is, update the stack template accordingly.
  3. Re-add any references to the cluster you might have removed in step 2

CDK

A process similar to that for CloudFormation can be followed for Aurora Serverless v1 clusters managed by the AWS CDK. When performing the steps mentioned above, note:

  1. DeletionPolicy is called removalPolicy in the CDK, refer to the documentation.
  2. For an overview of options when importing the cluster and instance into the stack, please refer to “How to import existing resources into AWS CDK Stacks” in the AWS DevOps & Developer Productivity Blog