AWS::RDS::DBCluster
The AWS::RDS::DBCluster
resource creates an Amazon Aurora DB cluster. For
more information, see Managing an Amazon Aurora DB
Cluster in the Amazon Aurora User Guide.
You can only create this resource in AWS Regions where Amazon Aurora is supported.
This topic covers the resource for Amazon Aurora DB clusters. For the documentation on the resource for Amazon RDS DB instances, see AWS::RDS::DBInstance.
Updating DB clusters
When properties labeled "Update requires: Replacement" are updated, AWS CloudFormation first creates a replacement DB cluster, then changes references from other dependent resources to point to the replacement DB cluster, and finally deletes the old DB cluster.
We highly recommend that you take a snapshot of the database before updating the stack. If you don't, you lose the data when AWS CloudFormation replaces your DB cluster. To preserve your data, perform the following procedure:
-
Deactivate any applications that are using the DB cluster so that there's no activity on the DB instance.
-
Create a snapshot of the DB cluster. For more information about creating DB snapshots, see Creating a DB Cluster Snapshot.
-
If you want to restore your DB cluster using a DB cluster snapshot, modify the updated template with your DB cluster changes and add the
SnapshotIdentifier
property with the ID of the DB cluster snapshot that you want to use.After you restore a DB cluster with a
SnapshotIdentifier
property, you must specify the sameSnapshotIdentifier
property for any future updates to the DB cluster. When you specify this property for an update, the DB cluster is not restored from the DB cluster snapshot again, and the data in the database is not changed. However, if you don't specify theSnapshotIdentifier
property, an empty DB cluster is created, and the original DB cluster is deleted. If you specify a property that is different from the previous snapshot restore property, a new DB cluster is restored from the specifiedSnapshotIdentifier
property, and the original DB cluster is deleted. -
Update the stack.
Currently, when you are updating the stack for an Aurora Serverless DB cluster, you can't include changes to
any other properties when you specify one of the following properties: PreferredBackupWindow
,
PreferredMaintenanceWindow
, and Port
. This limitation doesn't apply to provisioned
DB clusters.
For more information about updating other properties of this resource, see
ModifyDBCluster
. For more information about updating stacks, see
AWS
CloudFormation Stacks Updates.
Deleting DB clusters
The default DeletionPolicy
for AWS::RDS::DBCluster
resources
is Snapshot
. For more information about how AWS CloudFormation deletes
resources, see
DeletionPolicy Attribute.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::RDS::DBCluster", "Properties" : { "AssociatedRoles" :
[ DBClusterRole, ... ]
, "AvailabilityZones" :[ String, ... ]
, "BacktrackWindow" :Long
, "BackupRetentionPeriod" :Integer
, "CopyTagsToSnapshot" :Boolean
, "DatabaseName" :String
, "DBClusterIdentifier" :String
, "DBClusterParameterGroupName" :String
, "DBSubnetGroupName" :String
, "DeletionProtection" :Boolean
, "EnableCloudwatchLogsExports" :[ String, ... ]
, "EnableHttpEndpoint" :Boolean
, "EnableIAMDatabaseAuthentication" :Boolean
, "Engine" :String
, "EngineMode" :String
, "EngineVersion" :String
, "GlobalClusterIdentifier" :String
, "KmsKeyId" :String
, "MasterUsername" :String
, "MasterUserPassword" :String
, "Port" :Integer
, "PreferredBackupWindow" :String
, "PreferredMaintenanceWindow" :String
, "ReplicationSourceIdentifier" :String
, "RestoreType" :String
, "ScalingConfiguration" :ScalingConfiguration
, "SnapshotIdentifier" :String
, "SourceDBClusterIdentifier" :String
, "SourceRegion" :String
, "StorageEncrypted" :Boolean
, "Tags" :[ Tag, ... ]
, "UseLatestRestorableTime" :Boolean
, "VpcSecurityGroupIds" :[ String, ... ]
} }
YAML
Type: AWS::RDS::DBCluster Properties: AssociatedRoles:
- DBClusterRole
AvailabilityZones:- String
BacktrackWindow:Long
BackupRetentionPeriod:Integer
CopyTagsToSnapshot:Boolean
DatabaseName:String
DBClusterIdentifier:String
DBClusterParameterGroupName:String
DBSubnetGroupName:String
DeletionProtection:Boolean
EnableCloudwatchLogsExports:- String
EnableHttpEndpoint:Boolean
EnableIAMDatabaseAuthentication:Boolean
Engine:String
EngineMode:String
EngineVersion:String
GlobalClusterIdentifier:String
KmsKeyId:String
MasterUsername:String
MasterUserPassword:String
Port:Integer
PreferredBackupWindow:String
PreferredMaintenanceWindow:String
ReplicationSourceIdentifier:String
RestoreType:String
ScalingConfiguration:ScalingConfiguration
SnapshotIdentifier:String
SourceDBClusterIdentifier:String
SourceRegion:String
StorageEncrypted:Boolean
Tags:- Tag
UseLatestRestorableTime:Boolean
VpcSecurityGroupIds:- String
Properties
AssociatedRoles
-
Provides a list of the AWS Identity and Access Management (IAM) roles that are associated with the DB cluster. IAM roles that are associated with a DB cluster grant permission for the DB cluster to access other Amazon Web Services on your behalf.
Required: No
Type: List of DBClusterRole
Update requires: No interruption
AvailabilityZones
-
A list of Availability Zones (AZs) where instances in the DB cluster can be created. For information on AWS Regions and Availability Zones, see Choosing the Regions and Availability Zones in the Amazon Aurora User Guide.
Required: No
Type: List of String
Update requires: Replacement
BacktrackWindow
-
The target backtrack window, in seconds. To disable backtracking, set this value to 0.
Note Currently, Backtrack is only supported for Aurora MySQL DB clusters.
Default: 0
Constraints:
-
If specified, this value must be set to a number from 0 to 259,200 (72 hours).
Required: No
Type: Long
Update requires: No interruption
-
BackupRetentionPeriod
-
The number of days for which automated backups are retained.
Default: 1
Constraints:
-
Must be a value from 1 to 35
Required: No
Type: Integer
Update requires: No interruption
-
CopyTagsToSnapshot
-
A value that indicates whether to copy all tags from the DB cluster to snapshots of the DB cluster. The default is not to copy them.
Required: No
Type: Boolean
Update requires: No interruption
DatabaseName
-
The name of your database. If you don't provide a name, then Amazon RDS won't create a database in this DB cluster. For naming constraints, see Naming Constraints in the Amazon Aurora User Guide.
Required: No
Type: String
Update requires: Replacement
DBClusterIdentifier
-
The DB cluster identifier. This parameter is stored as a lowercase string.
Constraints:
-
Must contain from 1 to 63 letters, numbers, or hyphens.
-
First character must be a letter.
-
Can't end with a hyphen or contain two consecutive hyphens.
Example:
my-cluster1
Required: No
Type: String
Update requires: Replacement
-
DBClusterParameterGroupName
-
The name of the DB cluster parameter group to associate with this DB cluster.
Important If you apply a parameter group to an existing DB cluster, then its DB instances might need to reboot. This can result in an outage while the DB instances are rebooting.
If you apply a change to parameter group associated with a stopped DB cluster, then the update stack waits until the DB cluster is started.
To list all of the available DB cluster parameter group names, use the following command:
aws rds describe-db-cluster-parameter-groups --query "DBClusterParameterGroups[].DBClusterParameterGroupName" --output text
Required: No
Type: String
Update requires: No interruption
DBSubnetGroupName
-
A DB subnet group that you want to associate with this DB cluster.
If you are restoring a DB cluster to a point in time with
RestoreType
set tocopy-on-write
, and don't specify a DB subnet group name, then the DB cluster is restored with a default DB subnet group.Required: No
Type: String
Update requires: Replacement
DeletionProtection
-
A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled. By default, deletion protection is disabled.
Required: No
Type: Boolean
Update requires: No interruption
EnableCloudwatchLogsExports
-
The list of log types that need to be enabled for exporting to CloudWatch Logs. The values in the list depend on the DB engine being used. For more information, see Publishing Database Logs to Amazon CloudWatch Logs in the Amazon Aurora User Guide.
Aurora MySQL
Valid values:
audit
,error
,general
,slowquery
Aurora PostgreSQL
Valid values:
postgresql
Required: No
Type: List of String
Update requires: No interruption
EnableHttpEndpoint
-
A value that indicates whether to enable the HTTP endpoint for an Aurora Serverless DB cluster. By default, the HTTP endpoint is disabled.
When enabled, the HTTP endpoint provides a connectionless web service API for running SQL queries on the Aurora Serverless DB cluster. You can also query your database from inside the RDS console with the query editor.
For more information, see Using the Data API for Aurora Serverless in the Amazon Aurora User Guide.
Required: No
Type: Boolean
Update requires: No interruption
EnableIAMDatabaseAuthentication
-
A value that indicates whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts. By default, mapping is disabled.
For more information, see IAM Database Authentication in the Amazon Aurora User Guide.
Required: No
Type: Boolean
Update requires: No interruption
Engine
-
The name of the database engine to be used for this DB cluster.
Valid Values:
aurora
(for MySQL 5.6-compatible Aurora),aurora-mysql
(for MySQL 5.7-compatible Aurora), andaurora-postgresql
Required: Yes
Type: String
Update requires: Some interruptions
EngineMode
-
The DB engine mode of the DB cluster, either
provisioned
,serverless
,parallelquery
,global
, ormultimaster
.The
serverless
engine mode only supports Aurora Serverless v1. Currently, AWS CloudFormation doesn't support Aurora Serverless v2.The
parallelquery
engine mode isn't required for Aurora MySQL version 1.23 and higher 1.x versions, and version 2.09 and higher 2.x versions.The
global
engine mode isn't required for Aurora MySQL version 1.22 and higher 1.x versions, andglobal
engine mode isn't required for any 2.x versions.The
multimaster
engine mode only applies for DB clusters created with Aurora MySQL version 5.6.10a.For Aurora PostgreSQL, the
global
engine mode isn't required, and both theparallelquery
and themultimaster
engine modes currently aren't supported.Limitations and requirements apply to some DB engine modes. For more information, see the following sections in the Amazon Aurora User Guide:
Required: No
Type: String
Update requires: Replacement
EngineVersion
-
The version number of the database engine to use.
To list all of the available engine versions for
aurora
(for MySQL 5.6-compatible Aurora), use the following command:aws rds describe-db-engine-versions --engine aurora --query "DBEngineVersions[].EngineVersion"
To list all of the available engine versions for
aurora-mysql
(for MySQL 5.7-compatible Aurora), use the following command:aws rds describe-db-engine-versions --engine aurora-mysql --query "DBEngineVersions[].EngineVersion"
To list all of the available engine versions for
aurora-postgresql
, use the following command:aws rds describe-db-engine-versions --engine aurora-postgresql --query "DBEngineVersions[].EngineVersion"
Required: No
Type: String
Update requires: Some interruptions
GlobalClusterIdentifier
-
If you are configuring an Aurora global database cluster and want your Aurora DB cluster to be a secondary member in the global database cluster, specify the global cluster ID of the global database cluster. To define the primary database cluster of the global cluster, use the AWS::RDS::GlobalCluster resource.
If you aren't configuring a global database cluster, don't specify this property.
Note To remove the DB cluster from a global database cluster, specify an empty value for the
GlobalClusterIdentifier
property.For information about Aurora global databases, see Working with Amazon Aurora Global Databases in the Amazon Aurora User Guide.
Required: No
Type: String
Update requires: Some interruptions
KmsKeyId
-
The Amazon Resource Name (ARN) of the AWS KMS key that is used to encrypt the database instances in the DB cluster, such as
arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef
. If you enable theStorageEncrypted
property but don't specify this property, the default KMS key is used. If you specify this property, you must set theStorageEncrypted
property totrue
.If you specify the
SnapshotIdentifier
property, theStorageEncrypted
property value is inherited from the snapshot, and if the DB cluster is encrypted, the specifiedKmsKeyId
property is used.Required: No
Type: String
Update requires: Replacement
MasterUsername
-
The name of the master user for the DB cluster.
Note If you specify the
SourceDBClusterIdentifier
,SnapshotIdentifier
, orGlobalClusterIdentifier
property, don't specify this property. The value is inherited from the source DB cluster, the snapshot, or the primary DB cluster for the global database cluster, respectively.Required: Conditional
Type: String
Update requires: Replacement
MasterUserPassword
-
The master password for the DB instance.
Note If you specify the
SourceDBClusterIdentifier
,SnapshotIdentifier
, orGlobalClusterIdentifier
property, don't specify this property. The value is inherited from the source DB cluster, the snapshot, or the primary DB cluster for the global database cluster, respectively.Required: Conditional
Type: String
Update requires: No interruption
Port
-
The port number on which the DB instances in the DB cluster accept connections.
Default:
-
When
EngineMode
isprovisioned
,3306
(for both Aurora MySQL and Aurora PostgreSQL) -
When
EngineMode
isserverless
:-
3306
whenEngine
isaurora
oraurora-mysql
-
5432
whenEngine
isaurora-postgresql
-
Important The
No interruption
on update behavior only applies to DB clusters. If you are updating a DB instance, see Port for the AWS::RDS::DBInstance resource.Required: No
Type: Integer
Update requires: No interruption
-
PreferredBackupWindow
-
The daily time range during which automated backups are created. For more information, see Backup Window in the Amazon Aurora User Guide.
Constraints:
-
Must be in the format
hh24:mi-hh24:mi
. -
Must be in Universal Coordinated Time (UTC).
-
Must not conflict with the preferred maintenance window.
-
Must be at least 30 minutes.
Required: No
Type: String
Update requires: No interruption
-
PreferredMaintenanceWindow
-
The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC).
Format:
ddd:hh24:mi-ddd:hh24:mi
The default is a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week. To see the time blocks available, see Adjusting the Preferred DB Cluster Maintenance Window in the Amazon Aurora User Guide.
Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun.
Constraints: Minimum 30-minute window.
Required: No
Type: String
Update requires: No interruption
ReplicationSourceIdentifier
-
The Amazon Resource Name (ARN) of the source DB instance or DB cluster if this DB cluster is created as a read replica.
Required: No
Type: String
Update requires: No interruption
RestoreType
-
The type of restore to be performed. You can specify one of the following values:
-
full-copy
- The new DB cluster is restored as a full copy of the source DB cluster. -
copy-on-write
- The new DB cluster is restored as a clone of the source DB cluster.
Constraints: You can't specify
copy-on-write
if the engine version of the source DB cluster is earlier than 1.11.If you don't specify a
RestoreType
value, then the new DB cluster is restored as a full copy of the source DB cluster.Required: No
Type: String
Update requires: Replacement
-
ScalingConfiguration
-
The
ScalingConfiguration
property type specifies the scaling configuration of an Aurora Serverless DB cluster.Currently, AWS CloudFormation only supports Aurora Serverless v1. AWS CloudFormation doesn't support Aurora Serverless v2.
Required: No
Type: ScalingConfiguration
Update requires: No interruption
SnapshotIdentifier
-
The identifier for the DB snapshot or DB cluster snapshot to restore from.
You can use either the name or the Amazon Resource Name (ARN) to specify a DB cluster snapshot. However, you can use only the ARN to specify a DB snapshot.
After you restore a DB cluster with a
SnapshotIdentifier
property, you must specify the sameSnapshotIdentifier
property for any future updates to the DB cluster. When you specify this property for an update, the DB cluster is not restored from the snapshot again, and the data in the database is not changed. However, if you don't specify theSnapshotIdentifier
property, an empty DB cluster is created, and the original DB cluster is deleted. If you specify a property that is different from the previous snapshot restore property, a new DB cluster is restored from the specifiedSnapshotIdentifier
property, and the original DB cluster is deleted.If you specify the
SnapshotIdentifier
property to restore a DB cluster (as opposed to specifying it for DB cluster updates), then don't specify the following properties:-
GlobalClusterIdentifier
-
MasterUsername
-
MasterUserPassword
-
ReplicationSourceIdentifier
-
RestoreType
-
SourceDBClusterIdentifier
-
SourceRegion
-
StorageEncrypted
(for an encrypted snapshot) -
UseLatestRestorableTime
Constraints:
-
Must match the identifier of an existing Snapshot.
Required: No
Type: String
Update requires: Replacement
-
SourceDBClusterIdentifier
-
When restoring a DB cluster to a point in time, the identifier of the source DB cluster from which to restore.
Constraints:
-
Must match the identifier of an existing DBCluster.
Required: No
Type: String
Update requires: Replacement
-
SourceRegion
-
The AWS Region which contains the source DB cluster when replicating a DB cluster. For example,
us-east-1
.Required: No
Type: String
Update requires: Replacement
StorageEncrypted
-
Indicates whether the DB cluster is encrypted.
If you specify the
KmsKeyId
property, then you must enable encryption.If you specify the
SourceDBClusterIdentifier
property, don't specify this property. The value is inherited from the source DB cluster, and if the DB cluster is encrypted, the specifiedKmsKeyId
property is used.If you specify the
SnapshotIdentifier
and the specified snapshot is encrypted, don't specify this property. The value is inherited from the snapshot, and the specifiedKmsKeyId
property is used.If you specify the
SnapshotIdentifier
and the specified snapshot isn't encrypted, you can use this property to specify that the restored DB cluster is encrypted. Specify theKmsKeyId
property for the KMS key to use for encryption. If you don't want the restored DB cluster to be encrypted, then don't set this property or set it tofalse
.Required: No
Type: Boolean
Update requires: Replacement
Tags
-
Tags to assign to the DB cluster.
Required: No
Type: List of Tag
Update requires: No interruption
UseLatestRestorableTime
-
A value that indicates whether to restore the DB cluster to the latest restorable backup time. By default, the DB cluster is not restored to the latest restorable backup time.
Required: No
Type: Boolean
Update requires: Replacement
VpcSecurityGroupIds
-
A list of EC2 VPC security groups to associate with this DB cluster.
If you plan to update the resource, don't specify VPC security groups in a shared VPC.
Required: No
Type: List of String
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the name of the DB cluster.
For more information about using the Ref
function, see Ref.
Fn::GetAtt
The Fn::GetAtt
intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt
intrinsic function, see Fn::GetAtt.
Endpoint.Address
-
The connection endpoint for the DB cluster. For example:
mystack-mydbcluster-123456789012.us-east-2.rds.amazonaws.com
Endpoint.Port
-
The port number that will accept connections on this DB cluster. For example:
3306
ReadEndpoint.Address
-
The reader endpoint for the DB cluster. For example:
mystack-mydbcluster-ro-123456789012.us-east-2.rds.amazonaws.com
Examples
The following examples create DB clusters.
For an example that adds a scaling policy for a DB cluster with Application Auto Scaling, see Declaring a scaling policy for an Aurora DB cluster.
Creating an Amazon Aurora DB cluster with two DB instances
The following example creates an Amazon Aurora DB cluster and adds two DB instances to it. Because Amazon RDS automatically assigns a writer and reader DB instances in the cluster, use the cluster endpoint to read and write data, not the individual DB instance endpoints.
The example uses the time_zone
Aurora MySQL parameter. For
Aurora PostgreSQL, use the timezone
parameter instead.
JSON
{ "RDSCluster": { "Type": "AWS::RDS::DBCluster", "Properties": { "MasterUsername": { "Ref": "username" }, "MasterUserPassword": { "Ref": "password" }, "Engine": "aurora", "DBSubnetGroupName": { "Ref": "DBSubnetGroup" }, "DBClusterParameterGroupName": { "Ref": "RDSDBClusterParameterGroup" } } }, "RDSDBInstance1": { "Type": "AWS::RDS::DBInstance", "Properties": { "DBSubnetGroupName": { "Ref": "DBSubnetGroup" }, "DBParameterGroupName": { "Ref": "RDSDBParameterGroup" }, "Engine": "aurora", "DBClusterIdentifier": { "Ref": "RDSCluster" }, "PubliclyAccessible": "true", "AvailabilityZone": { "Fn::GetAtt": [ "Subnet1", "AvailabilityZone" ] }, "DBInstanceClass": "db.r3.xlarge" } }, "RDSDBInstance2": { "Type": "AWS::RDS::DBInstance", "Properties": { "DBSubnetGroupName": { "Ref": "DBSubnetGroup" }, "DBParameterGroupName": { "Ref": "RDSDBParameterGroup" }, "Engine": "aurora", "DBClusterIdentifier": { "Ref": "RDSCluster" }, "PubliclyAccessible": "true", "AvailabilityZone": { "Fn::GetAtt": [ "Subnet2", "AvailabilityZone" ] }, "DBInstanceClass": "db.r3.xlarge" } }, "RDSDBClusterParameterGroup": { "Type": "AWS::RDS::DBClusterParameterGroup", "Properties": { "Description": "CloudFormation Sample Aurora Cluster Parameter Group", "Family": "aurora5.6", "Parameters": { "time_zone": "US/Eastern" } } }, "RDSDBParameterGroup": { "Type": "AWS::RDS::DBParameterGroup", "Properties": { "Description": "CloudFormation Sample Aurora Parameter Group", "Family": "aurora5.6", "Parameters": { "sql_mode": "IGNORE_SPACE", "max_allowed_packet": 1024, "innodb_buffer_pool_size": "{DBInstanceClassMemory*3/4}" } } } }
YAML
RDSCluster: Properties: DBClusterParameterGroupName: Ref: RDSDBClusterParameterGroup DBSubnetGroupName: Ref: DBSubnetGroup Engine: aurora MasterUserPassword: Ref: password MasterUsername: Ref: username Type: "AWS::RDS::DBCluster" RDSDBClusterParameterGroup: Properties: Description: "CloudFormation Sample Aurora Cluster Parameter Group" Family: aurora5.6 Parameters: time_zone: US/Eastern Type: "AWS::RDS::DBClusterParameterGroup" RDSDBInstance1: Properties: AvailabilityZone: Fn::GetAtt: - Subnet1 - AvailabilityZone DBClusterIdentifier: Ref: RDSCluster DBInstanceClass: db.r3.xlarge DBParameterGroupName: Ref: RDSDBParameterGroup DBSubnetGroupName: Ref: DBSubnetGroup Engine: aurora PubliclyAccessible: "true" Type: "AWS::RDS::DBInstance" RDSDBInstance2: Properties: AvailabilityZone: Fn::GetAtt: - Subnet2 - AvailabilityZone DBClusterIdentifier: Ref: RDSCluster DBInstanceClass: db.r3.xlarge DBParameterGroupName: Ref: RDSDBParameterGroup DBSubnetGroupName: Ref: DBSubnetGroup Engine: aurora PubliclyAccessible: "true" Type: "AWS::RDS::DBInstance" RDSDBParameterGroup: Type: 'AWS::RDS::DBParameterGroup' Properties: Description: CloudFormation Sample Aurora Parameter Group Family: aurora5.6 Parameters: sql_mode: IGNORE_SPACE max_allowed_packet: 1024 innodb_buffer_pool_size: '{DBInstanceClassMemory*3/4}'
Creating an Amazon Aurora DB cluster that exports logs to Amazon CloudWatch Logs
The following example creates an Amazon Aurora PostgreSQL DB cluster that exports logs to Amazon CloudWatch Logs. For more information about exporting Aurora DB cluster logs to Amazon CloudWatch Logs, see Publishing Database Logs to Amazon CloudWatch Logs in the Amazon Aurora User Guide.
JSON
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Sample Template for sending Aurora DB cluster logs to CloudWatch Logs: Sample template showing how to create an Aurora PostgreSQL DB cluster that exports logs to CloudWatch Logs. **WARNING** This template enables log exports to CloudWatch Logs. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters" : { "DBUsername" : { "NoEcho" : "true", "Description" : "Username for PostgreSQL database access", "Type" : "String", "MinLength" : "1", "MaxLength" : "16", "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." }, "DBPassword" : { "NoEcho" : "true", "Description" : "Password for PostgreSQL database access", "Type" : "String", "MinLength" : "8", "MaxLength" : "41", "AllowedPattern" : "[a-zA-Z0-9]*", "ConstraintDescription" : "must contain only alphanumeric characters." } }, "Resources" : { "RDSCluster" : { "Type": "AWS::RDS::DBCluster", "Properties" : { "MasterUsername" : { "Ref" : "DBUsername" }, "MasterUserPassword" : { "Ref" : "DBPassword" }, "DBClusterIdentifier" : "aurora-postgresql-cluster", "Engine" : "aurora-postgresql", "EngineVersion" : "10.7", "DBClusterParameterGroupName" : "default.aurora-postgresql10", "EnableCloudwatchLogsExports" : ["postgresql"] } }, "RDSDBInstance1": { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBInstanceIdentifier" : "aurora-postgresql-instance1", "Engine" : "aurora-postgresql", "DBClusterIdentifier" : { "Ref" : "RDSCluster" }, "PubliclyAccessible" : "true", "DBInstanceClass" : "db.r4.large" } }, "RDSDBInstance2": { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBInstanceIdentifier" : "aurora-postgresql-instance2", "Engine" : "aurora-postgresql", "DBClusterIdentifier" : { "Ref" : "RDSCluster" }, "PubliclyAccessible" : "true", "DBInstanceClass" : "db.r4.large" } }, } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Description: >- AWS CloudFormation Sample Template for sending Aurora DB cluster logs to CloudWatch Logs: Sample template showing how to create an Aurora PostgreSQL DB cluster that exports logs to CloudWatch Logs. **WARNING** This template enables log exports to CloudWatch Logs. You will be billed for the AWS resources used if you create a stack from this template. Parameters: DBUsername: NoEcho: 'true' Description: Username for PostgreSQL database access Type: String MinLength: '1' MaxLength: '16' AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*' ConstraintDescription: must begin with a letter and contain only alphanumeric characters. DBPassword: NoEcho: 'true' Description: Password for PostgreSQL database access Type: String MinLength: '8' MaxLength: '41' AllowedPattern: '[a-zA-Z0-9]*' ConstraintDescription: must contain only alphanumeric characters. Resources: RDSCluster: Type: 'AWS::RDS::DBCluster' Properties: MasterUsername: !Ref DBUsername MasterUserPassword: !Ref DBPassword DBClusterIdentifier: aurora-postgresql-cluster Engine: aurora-postgresql EngineVersion: '10.7' DBClusterParameterGroupName: default.aurora-postgresql10 EnableCloudwatchLogsExports: - postgresql RDSDBInstance1: Type: 'AWS::RDS::DBInstance' Properties: DBInstanceIdentifier: aurora-postgresql-instance1 Engine: aurora-postgresql DBClusterIdentifier: !Ref RDSCluster PubliclyAccessible: 'true' DBInstanceClass: db.r4.large RDSDBInstance2: Type: 'AWS::RDS::DBInstance' Properties: DBInstanceIdentifier: aurora-postgresql-instance2 Engine: aurora-postgresql DBClusterIdentifier: !Ref RDSCluster PubliclyAccessible: 'true' DBInstanceClass: db.r4.large
Creating an Amazon Aurora Serverless DB cluster
The following example creates an Amazon Aurora Serverless DB cluster. An Aurora Serverless DB cluster is a DB cluster that automatically starts up, shuts down, and scales up or down its compute capacity based on your application's needs. For more information about Aurora Serverless DB clusters, see Using Amazon Aurora Serverless in the Amazon Aurora User Guide.
This example creates an Aurora MySQL Serverless DB cluster by setting
Engine
to aurora
and
EngineVersion
to 5.6.10a
. To create an Aurora
PostgreSQL Serverless DB cluster, set Engine
to
aurora-postgresql
and EngineVersion
to
10.7
.
Currently, AWS CloudFormation only supports Aurora Serverless v1. AWS CloudFormation doesn't support Aurora Serverless v2.
JSON
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Sample Template AuroraServerlessDBCluster: Sample template showing how to create an Amazon Aurora Serverless DB cluster. **WARNING** This template creates an Amazon Aurora DB cluster. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters" : { "DBUsername" : { "NoEcho" : "true", "Description" : "Username for MySQL database access", "Type" : "String", "MinLength" : "1", "MaxLength" : "16", "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." }, "DBPassword" : { "NoEcho" : "true", "Description" : "Password MySQL database access", "Type" : "String", "MinLength" : "8", "MaxLength" : "41", "AllowedPattern" : "[a-zA-Z0-9]*", "ConstraintDescription" : "must contain only alphanumeric characters." } }, "Resources" : { "RDSCluster" : { "Type": "AWS::RDS::DBCluster", "Properties" : { "MasterUsername" : { "Ref": "DBUsername" }, "MasterUserPassword" : { "Ref": "DBPassword" }, "DBClusterIdentifier" : "my-serverless-cluster", "Engine" : "aurora", "EngineVersion" : "5.6.10a", "EngineMode" : "serverless", "ScalingConfiguration" : { "AutoPause" : true, "MinCapacity" : 4, "MaxCapacity" : 32, "SecondsUntilAutoPause" : 1000 } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Description: >- AWS CloudFormation Sample Template AuroraServerlessDBCluster: Sample template showing how to create an Amazon Aurora Serverless DB cluster. **WARNING** This template creates an Amazon Aurora DB cluster. You will be billed for the AWS resources used if you create a stack from this template. Parameters: DBUsername: NoEcho: 'true' Description: Username for MySQL database access Type: String MinLength: '1' MaxLength: '16' AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*' ConstraintDescription: must begin with a letter and contain only alphanumeric characters. DBPassword: NoEcho: 'true' Description: Password MySQL database access Type: String MinLength: '8' MaxLength: '41' AllowedPattern: '[a-zA-Z0-9]*' ConstraintDescription: must contain only alphanumeric characters. Resources: RDSCluster: Type: 'AWS::RDS::DBCluster' Properties: MasterUsername: !Ref DBUsername MasterUserPassword: !Ref DBPassword DBClusterIdentifier: my-serverless-cluster Engine: aurora EngineVersion: 5.6.10a EngineMode: serverless ScalingConfiguration: AutoPause: true MinCapacity: 4 MaxCapacity: 32 SecondsUntilAutoPause: 1000