I'm creating an AWS Aurora Serverless V2 Postgres database cluster (AWS::RDS::DBCluster
) using Cloudformation and Serverless Framework (see below). It's unclear if I should also create two database instances (AWS::RDS::DBInstance
) so that the cluster has a reader and writer instance available?
When I run through the AWS RDS Wizard the Aurora Serverless V2 cluster is automatically set up with two instances (reader and writer). I'm assuming I should do the same when creating the CloudFormation script?
Cluster
Type: AWS::RDS::DBCluster
DeletionPolicy: Delete
Properties:
DBClusterIdentifier: db-test-cluster
Engine: aurora-postgresql
MasterUsername: username_from_secrets_manager
MasterUserPassword: password_from_secrets_manager
ServerlessV2ScalingConfiguration:
MinCapacity: 0.5
MaxCapacity: 2
BackupRetentionPeriod: 1
DatabaseName: test-db
EngineMode: provisioned
Port: 5432
Tags:
- Key: "Name"
Value: db-test-cluster
DbInstance 1 - reader
Type: AWS::RDS::DBInstance
Properties:
Engine: aurora-postgresql
DBInstanceClass: db.serverless
DBClusterIdentifier: !Ref auroraServerlessCluster
DbInstance 2 - writer
Type: AWS::RDS::DBInstance
Properties:
Engine: aurora-postgresql
DBInstanceClass: db.serverless
DBClusterIdentifier: !Ref auroraServerlessCluster
Do I need to specify these two db instances? When I don't specify these two instances my cluster is stick with "creating" as the status.
There's no requirement to have any read-replica instances in an Aurora cluster (serverless or not). You can create an Aurora cluster with a single primary writer instance and nothing else. You can even create a cluster with no instances if you want, although that certainly has limited functionality.