Skip to content
v2.278.0

ClusterInstance Class ​

Create an RDS Aurora Cluster Instance.

You can create either provisioned or serverless v2 instances.

Example ​

ts
declare const vpc: ec2.Vpc;
const myCluster = new rds.DatabaseCluster(this, 'Database', {
  engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
  writer: rds.ClusterInstance.provisioned('writer', {
    instanceType: ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.XLARGE4),
  }),
  serverlessV2MinCapacity: 6.5,
  serverlessV2MaxCapacity: 64,
  readers: [
    // will be put in promotion tier 1 and will scale with the writer
    rds.ClusterInstance.serverlessV2('reader1', { scaleWithWriter: true }),
    // will be put in promotion tier 2 and will not scale with the writer
    rds.ClusterInstance.serverlessV2('reader2'),
  ],
  vpc,
});
python
# vpc: ec2.Vpc

my_cluster = rds.DatabaseCluster(self, "Database",
    engine=rds.DatabaseClusterEngine.aurora_mysql(version=rds.AuroraMysqlEngineVersion.VER_2_08_1),
    writer=rds.ClusterInstance.provisioned("writer",
        instance_type=ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.XLARGE4)
    ),
    serverless_v2_min_capacity=6.5,
    serverless_v2_max_capacity=64,
    readers=[
        # will be put in promotion tier 1 and will scale with the writer
        rds.ClusterInstance.serverless_v2("reader1", scale_with_writer=True),
        # will be put in promotion tier 2 and will not scale with the writer
        rds.ClusterInstance.serverless_v2("reader2")
    ],
    vpc=vpc
)
java
Vpc vpc;

DatabaseCluster myCluster = DatabaseCluster.Builder.create(this, "Database")
        .engine(DatabaseClusterEngine.auroraMysql(AuroraMysqlClusterEngineProps.builder().version(AuroraMysqlEngineVersion.VER_2_08_1).build()))
        .writer(ClusterInstance.provisioned("writer", ProvisionedClusterInstanceProps.builder()
                .instanceType(InstanceType.of(InstanceClass.R6G, InstanceSize.XLARGE4))
                .build()))
        .serverlessV2MinCapacity(6.5)
        .serverlessV2MaxCapacity(64)
        .readers(List.of(ClusterInstance.serverlessV2("reader1", ServerlessV2ClusterInstanceProps.builder().scaleWithWriter(true).build()), ClusterInstance.serverlessV2("reader2")))
        .vpc(vpc)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;

var myCluster = new DatabaseCluster(this, "Database", new DatabaseClusterProps {
    Engine = DatabaseClusterEngine.AuroraMysql(new AuroraMysqlClusterEngineProps { Version = AuroraMysqlEngineVersion.VER_2_08_1 }),
    Writer = ClusterInstance.Provisioned("writer", new ProvisionedClusterInstanceProps {
        InstanceType = InstanceType.Of(InstanceClass.R6G, InstanceSize.XLARGE4)
    }),
    ServerlessV2MinCapacity = 6.5,
    ServerlessV2MaxCapacity = 64,
    Readers = new [] { ClusterInstance.ServerlessV2("reader1", new ServerlessV2ClusterInstanceProps { ScaleWithWriter = true }), ClusterInstance.ServerlessV2("reader2") },
    Vpc = vpc
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc

myCluster := rds.NewDatabaseCluster(this, jsii.String("Database"), &DatabaseClusterProps{
	Engine: rds.DatabaseClusterEngine_AuroraMysql(&AuroraMysqlClusterEngineProps{
		Version: rds.AuroraMysqlEngineVersion_VER_2_08_1(),
	}),
	Writer: rds.ClusterInstance_Provisioned(jsii.String("writer"), &ProvisionedClusterInstanceProps{
		InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_R6G, ec2.InstanceSize_XLARGE4),
	}),
	ServerlessV2MinCapacity: jsii.Number(6.5),
	ServerlessV2MaxCapacity: jsii.Number(64),
	Readers: []IClusterInstance{
		rds.ClusterInstance_ServerlessV2(jsii.String("reader1"), &ServerlessV2ClusterInstanceProps{
			ScaleWithWriter: jsii.Boolean(true),
		}),
		rds.ClusterInstance_*ServerlessV2(jsii.String("reader2")),
	},
	Vpc: Vpc,
})

Methods ​

bind(scope: Construct, cluster: IDatabaseCluster, props: ClusterInstanceBindOptions): IAuroraClusterInstancedef bind(self, scope: Construct, cluster: IDatabaseCluster, props: ClusterInstanceBindOptions) -> IAuroraClusterInstancepublic IAuroraClusterInstance bind(Construct scope, IDatabaseCluster cluster, ClusterInstanceBindOptions props)public IAuroraClusterInstance Bind(Construct scope, IDatabaseCluster cluster, ClusterInstanceBindOptions props)func Bind(Scope Construct, Cluster IDatabaseCluster, Props ClusterInstanceBindOptions) IAuroraClusterInstance #
Add the ClusterInstance to the cluster.
provisioned(id: string, props?: ProvisionedClusterInstanceProps): IClusterInstance@staticmethod def provisioned(id: str, props: typing.Optional[ProvisionedClusterInstanceProps] = None) -> IClusterInstancepublic static IClusterInstance provisioned(String id, ProvisionedClusterInstanceProps props)public static IClusterInstance Provisioned(string id, ProvisionedClusterInstanceProps? props = null)func Provisioned(Id *string, Props ProvisionedClusterInstanceProps) IClusterInstance static #
Add a provisioned instance to the cluster.
example
ts
rds.ClusterInstance.provisioned('ClusterInstance', {
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.XLARGE4),
});
serverlessV2(id: string, props?: ServerlessV2ClusterInstanceProps): IClusterInstance@staticmethod def serverless_v2(id: str, props: typing.Optional[ServerlessV2ClusterInstanceProps] = None) -> IClusterInstancepublic static IClusterInstance serverlessV2(String id, ServerlessV2ClusterInstanceProps props)public static IClusterInstance ServerlessV2(string id, ServerlessV2ClusterInstanceProps? props = null)func ServerlessV2(Id *string, Props ServerlessV2ClusterInstanceProps) IClusterInstance static #
Add a serverless v2 instance to the cluster.
example
ts
rds.ClusterInstance.serverlessV2('ClusterInstance', {
  scaleWithWriter: true,
});