interface ServerlessClusterProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.RDS.ServerlessClusterProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsrds#ServerlessClusterProps |
Java | software.amazon.awscdk.services.rds.ServerlessClusterProps |
Python | aws_cdk.aws_rds.ServerlessClusterProps |
TypeScript (source) | aws-cdk-lib » aws_rds » ServerlessClusterProps |
Properties for a new Aurora Serverless v1 Cluster.
Example
// Create username and password secret for DB Cluster
const secret = new rds.DatabaseSecret(this, 'AuroraSecret', {
username: 'clusteradmin',
});
// The VPC to place the cluster in
const vpc = new ec2.Vpc(this, 'AuroraVpc');
// Create the serverless cluster, provide all values needed to customise the database.
const cluster = new rds.ServerlessCluster(this, 'AuroraCluster', {
engine: rds.DatabaseClusterEngine.AURORA_MYSQL,
vpc,
credentials: { username: 'clusteradmin' },
clusterIdentifier: 'db-endpoint-test',
defaultDatabaseName: 'demos',
});
// Build a data source for AppSync to access the database.
declare const api: appsync.GraphqlApi;
const rdsDS = api.addRdsDataSource('rds', cluster, secret, 'demos');
// Set up a resolver for an RDS query.
rdsDS.createResolver('QueryGetDemosRdsResolver', {
typeName: 'Query',
fieldName: 'getDemosRds',
requestMappingTemplate: appsync.MappingTemplate.fromString(`
{
"version": "2018-05-29",
"statements": [
"SELECT * FROM demos"
]
}
`),
responseMappingTemplate: appsync.MappingTemplate.fromString(`
$utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
`),
});
// Set up a resolver for an RDS mutation.
rdsDS.createResolver('MutationAddDemoRdsResolver', {
typeName: 'Mutation',
fieldName: 'addDemoRds',
requestMappingTemplate: appsync.MappingTemplate.fromString(`
{
"version": "2018-05-29",
"statements": [
"INSERT INTO demos VALUES (:id, :version)",
"SELECT * WHERE id = :id"
],
"variableMap": {
":id": $util.toJson($util.autoId()),
":version": $util.toJson($ctx.args.version)
}
}
`),
responseMappingTemplate: appsync.MappingTemplate.fromString(`
$utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])
`),
});
Properties
Name | Type | Description |
---|---|---|
engine | ICluster | What kind of database to start. |
backup | Duration | The number of days during which automatic DB snapshots are retained. |
cluster | string | An optional identifier for the cluster. |
copy | boolean | Whether to copy tags to the snapshot when a snapshot is created. |
credentials? | Credentials | Credentials for the administrative user. |
default | string | Name of a database which is automatically created inside the cluster. |
deletion | boolean | Indicates whether the DB cluster should have deletion protection enabled. |
enable | boolean | Whether to enable the Data API. |
parameter | IParameter | Additional parameters to pass to the database engine. |
removal | Removal | The removal policy to apply when the cluster and its instances are removed from the stack or replaced during an update. |
scaling? | Serverless | Scaling configuration of an Aurora Serverless database cluster. |
security | ISecurity [] | Security group. |
storage | IKey | The KMS key for storage encryption. |
subnet | ISubnet | Existing subnet group for the cluster. |
vpc? | IVpc | The VPC that this Aurora Serverless v1 Cluster has been created in. |
vpc | Subnet | Where to place the instances within the VPC. |
engine
Type:
ICluster
What kind of database to start.
backupRetention?
Type:
Duration
(optional, default: Duration.days(1))
The number of days during which automatic DB snapshots are retained.
Automatic backup retention cannot be disabled on serverless clusters. Must be a value from 1 day to 35 days.
clusterIdentifier?
Type:
string
(optional, default: A name is automatically generated.)
An optional identifier for the cluster.
copyTagsToSnapshot?
Type:
boolean
(optional, default: true)
Whether to copy tags to the snapshot when a snapshot is created.
credentials?
Type:
Credentials
(optional, default: A username of 'admin' and SecretsManager-generated password)
Credentials for the administrative user.
defaultDatabaseName?
Type:
string
(optional, default: Database is not created in cluster.)
Name of a database which is automatically created inside the cluster.
deletionProtection?
Type:
boolean
(optional, default: true if removalPolicy is RETAIN, false otherwise)
Indicates whether the DB cluster should have deletion protection enabled.
enableDataApi?
Type:
boolean
(optional, default: false)
Whether to enable the Data API.
See also: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html
parameterGroup?
Type:
IParameter
(optional, default: no parameter group.)
Additional parameters to pass to the database engine.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.SNAPSHOT (remove the cluster and instances, but retain a snapshot of the data))
The removal policy to apply when the cluster and its instances are removed from the stack or replaced during an update.
scaling?
Type:
Serverless
(optional, default: Serverless cluster is automatically paused after 5 minutes of being idle.
minimum capacity: 2 ACU
maximum capacity: 16 ACU)
Scaling configuration of an Aurora Serverless database cluster.
securityGroups?
Type:
ISecurity
[]
(optional, default: a new security group is created if vpc
was provided.
If the vpc
property was not provided, no VPC security groups will be associated with the DB cluster.)
Security group.
storageEncryptionKey?
Type:
IKey
(optional, default: the default master key will be used for storage encryption)
The KMS key for storage encryption.
subnetGroup?
Type:
ISubnet
(optional, default: a new subnet group is created if vpc
was provided.
If the vpc
property was not provided, no subnet group will be associated with the DB cluster)
Existing subnet group for the cluster.
vpc?
Type:
IVpc
(optional, default: the default VPC in the account and region will be used)
The VPC that this Aurora Serverless v1 Cluster has been created in.
vpcSubnets?
Type:
Subnet
(optional, default: the VPC default strategy if not specified.)
Where to place the instances within the VPC.
If provided, the vpc
property must also be specified.