ClusterInstance

class aws_cdk.aws_rds.ClusterInstance(*args: Any, **kwargs)

Bases: object

Create an RDS Aurora Cluster Instance.

You can create either provisioned or serverless v2 instances.

Example:

# 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
)

Methods

bind(scope, cluster, *, monitoring_interval=None, monitoring_role=None, promotion_tier=None, removal_policy=None, subnet_group=None)

Add the ClusterInstance to the cluster.

Parameters:
  • scope (Construct) –

  • cluster (IDatabaseCluster) –

  • monitoring_interval (Optional[Duration]) – The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instances. Default: no enhanced monitoring

  • monitoring_role (Optional[IRole]) – Role that will be used to manage DB instances monitoring. Default: - A role is automatically created for you

  • promotion_tier (Union[int, float, None]) – The promotion tier of the cluster instance. This matters more for serverlessV2 instances. If a serverless instance is in tier 0-1 then it will scale with the writer. For provisioned instances this just determines the failover priority. If multiple instances have the same priority then one will be picked at random Default: 2

  • removal_policy (Optional[RemovalPolicy]) – The removal policy on the cluster. Default: - RemovalPolicy.DESTROY (cluster snapshot can restore)

  • subnet_group (Optional[ISubnetGroup]) – Existing subnet group for the cluster. This is only needed when using the isFromLegacyInstanceProps Default: - cluster subnet group is used

Return type:

IAuroraClusterInstance

Static Methods

classmethod provisioned(id, *, instance_type=None, promotion_tier=None, allow_major_version_upgrade=None, auto_minor_version_upgrade=None, ca_certificate=None, enable_performance_insights=None, instance_identifier=None, is_from_legacy_instance_props=None, parameter_group=None, parameters=None, performance_insight_encryption_key=None, performance_insight_retention=None, preferred_maintenance_window=None, publicly_accessible=None)

Add a provisioned instance to the cluster.

Parameters:
  • id (str) –

  • instance_type (Optional[InstanceType]) – The cluster instance type. Default: db.t3.medium

  • promotion_tier (Union[int, float, None]) – The promotion tier of the cluster instance. Can be between 0-15 For provisioned instances this just determines the failover priority. If multiple instances have the same priority then one will be picked at random Default: 2

  • allow_major_version_upgrade (Optional[bool]) – Whether to allow upgrade of major version for the DB instance. Default: - false

  • auto_minor_version_upgrade (Optional[bool]) – Whether to enable automatic upgrade of minor version for the DB instance. Default: - true

  • ca_certificate (Optional[CaCertificate]) – The identifier of the CA certificate for this DB cluster’s instances. Specifying or updating this property triggers a reboot. For RDS DB engines: Default: - RDS will choose a certificate authority

  • enable_performance_insights (Optional[bool]) – Whether to enable Performance Insights for the DB instance. Default: - false, unless performanceInsightRetention or performanceInsightEncryptionKey is set.

  • instance_identifier (Optional[str]) – The identifier for the database instance. Default: - CloudFormation generated identifier

  • is_from_legacy_instance_props (Optional[bool]) – Only used for migrating existing clusters from using instanceProps to writer and readers. Default: false

  • parameter_group (Optional[IParameterGroup]) – The DB parameter group to associate with the instance. This is only needed if you need to configure different parameter groups for each individual instance, otherwise you should not provide this and just use the cluster parameter group Default: the cluster parameter group is used

  • parameters (Optional[Mapping[str, str]]) – The parameters in the DBParameterGroup to create automatically. You can only specify parameterGroup or parameters but not both. You need to use a versioned engine to auto-generate a DBParameterGroup. Default: - None

  • performance_insight_encryption_key (Optional[IKey]) – The AWS KMS key for encryption of Performance Insights data. Default: - default master key

  • performance_insight_retention (Optional[PerformanceInsightRetention]) – The amount of time, in days, to retain Performance Insights data. Default: 7

  • preferred_maintenance_window (Optional[str]) – A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). Example: ‘Sun:23:45-Mon:00:15’ Default: - 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.

  • publicly_accessible (Optional[bool]) – Indicates whether the DB instance is an internet-facing instance. If not specified, the cluster’s vpcSubnets will be used to determine if the instance is internet-facing or not. Default: - true if the cluster’s vpcSubnets is subnetType: SubnetType.PUBLIC, false otherwise

Return type:

IClusterInstance

Example:

rds.ClusterInstance.provisioned("ClusterInstance",
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.XLARGE4)
)
classmethod serverless_v2(id, *, scale_with_writer=None, allow_major_version_upgrade=None, auto_minor_version_upgrade=None, ca_certificate=None, enable_performance_insights=None, instance_identifier=None, is_from_legacy_instance_props=None, parameter_group=None, parameters=None, performance_insight_encryption_key=None, performance_insight_retention=None, preferred_maintenance_window=None, publicly_accessible=None)

Add a serverless v2 instance to the cluster.

Parameters:
  • id (str) –

  • scale_with_writer (Optional[bool]) – Only applicable to reader instances. If this is true then the instance will be placed in promotion tier 1, otherwise it will be placed in promotion tier 2. For serverless v2 instances this means: - true: The serverless v2 reader will scale to match the writer instance (provisioned or serverless) - false: The serverless v2 reader will scale with the read workfload on the instance Default: false

  • allow_major_version_upgrade (Optional[bool]) – Whether to allow upgrade of major version for the DB instance. Default: - false

  • auto_minor_version_upgrade (Optional[bool]) – Whether to enable automatic upgrade of minor version for the DB instance. Default: - true

  • ca_certificate (Optional[CaCertificate]) – The identifier of the CA certificate for this DB cluster’s instances. Specifying or updating this property triggers a reboot. For RDS DB engines: Default: - RDS will choose a certificate authority

  • enable_performance_insights (Optional[bool]) – Whether to enable Performance Insights for the DB instance. Default: - false, unless performanceInsightRetention or performanceInsightEncryptionKey is set.

  • instance_identifier (Optional[str]) – The identifier for the database instance. Default: - CloudFormation generated identifier

  • is_from_legacy_instance_props (Optional[bool]) – Only used for migrating existing clusters from using instanceProps to writer and readers. Default: false

  • parameter_group (Optional[IParameterGroup]) – The DB parameter group to associate with the instance. This is only needed if you need to configure different parameter groups for each individual instance, otherwise you should not provide this and just use the cluster parameter group Default: the cluster parameter group is used

  • parameters (Optional[Mapping[str, str]]) – The parameters in the DBParameterGroup to create automatically. You can only specify parameterGroup or parameters but not both. You need to use a versioned engine to auto-generate a DBParameterGroup. Default: - None

  • performance_insight_encryption_key (Optional[IKey]) – The AWS KMS key for encryption of Performance Insights data. Default: - default master key

  • performance_insight_retention (Optional[PerformanceInsightRetention]) – The amount of time, in days, to retain Performance Insights data. Default: 7

  • preferred_maintenance_window (Optional[str]) – A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). Example: ‘Sun:23:45-Mon:00:15’ Default: - 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.

  • publicly_accessible (Optional[bool]) – Indicates whether the DB instance is an internet-facing instance. If not specified, the cluster’s vpcSubnets will be used to determine if the instance is internet-facing or not. Default: - true if the cluster’s vpcSubnets is subnetType: SubnetType.PUBLIC, false otherwise

Return type:

IClusterInstance

Example:

rds.ClusterInstance.serverless_v2("ClusterInstance",
    scale_with_writer=True
)