Class DatabaseCluster

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IResource, IConnectable, IDatabaseCluster, ISecretAttachmentTarget, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-04T00:39:38.653Z") @Stability(Stable) public class DatabaseCluster extends DatabaseClusterBase
Create a clustered database with a given number of instances.

Example:

 Vpc vpc;
 DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Database")
         .engine(DatabaseClusterEngine.auroraMysql(AuroraMysqlClusterEngineProps.builder().version(AuroraMysqlEngineVersion.VER_3_01_0).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();
 
  • Constructor Details

    • DatabaseCluster

      protected DatabaseCluster(software.amazon.jsii.JsiiObjectRef objRef)
    • DatabaseCluster

      protected DatabaseCluster(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • DatabaseCluster

      @Stability(Stable) public DatabaseCluster(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DatabaseClusterProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromDatabaseClusterAttributes

      @Stability(Stable) @NotNull public static IDatabaseCluster fromDatabaseClusterAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DatabaseClusterAttributes attrs)
      Import an existing DatabaseCluster from properties.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addRotationMultiUser

      @Stability(Stable) @NotNull public SecretRotation addRotationMultiUser(@NotNull String id, @NotNull RotationMultiUserOptions options)
      Adds the multi user rotation to this cluster.

      See Alternating users rotation strategy

      Parameters:
      id - This parameter is required.
      options - This parameter is required.
    • addRotationSingleUser

      @Stability(Stable) @NotNull public SecretRotation addRotationSingleUser(@Nullable RotationSingleUserOptions options)
      Adds the single user rotation of the master password to this cluster.

      See Single user rotation strategy

      Parameters:
      options -
    • addRotationSingleUser

      @Stability(Stable) @NotNull public SecretRotation addRotationSingleUser()
      Adds the single user rotation of the master password to this cluster.

      See Single user rotation strategy

    • metricACUUtilization

      @Stability(Stable) @NotNull public Metric metricACUUtilization(@Nullable MetricOptions props)
      This value is represented as a percentage.

      It's calculated as the value of the ServerlessDatabaseCapacity metric divided by the maximum ACU value of the DB cluster.

      If this metric approaches a value of 100.0, the DB instance has scaled up as high as it can. Consider increasing the maximum ACU setting for the cluster.

      Parameters:
      props -
    • metricACUUtilization

      @Stability(Stable) @NotNull public Metric metricACUUtilization()
      This value is represented as a percentage.

      It's calculated as the value of the ServerlessDatabaseCapacity metric divided by the maximum ACU value of the DB cluster.

      If this metric approaches a value of 100.0, the DB instance has scaled up as high as it can. Consider increasing the maximum ACU setting for the cluster.

    • metricServerlessDatabaseCapacity

      @Stability(Stable) @NotNull public Metric metricServerlessDatabaseCapacity(@Nullable MetricOptions props)
      As a cluster-level metric, it represents the average of the ServerlessDatabaseCapacity values of all the Aurora Serverless v2 DB instances in the cluster.

      Parameters:
      props -
    • metricServerlessDatabaseCapacity

      @Stability(Stable) @NotNull public Metric metricServerlessDatabaseCapacity()
      As a cluster-level metric, it represents the average of the ServerlessDatabaseCapacity values of all the Aurora Serverless v2 DB instances in the cluster.
    • getCloudwatchLogGroups

      @Stability(Stable) @NotNull public Map<String,ILogGroup> getCloudwatchLogGroups()
      The log group is created when cloudwatchLogsExports is set.

      Each export value will create a separate log group.

    • getClusterEndpoint

      @Stability(Stable) @NotNull public Endpoint getClusterEndpoint()
      The endpoint to use for read/write operations.
      Specified by:
      getClusterEndpoint in interface IDatabaseCluster
      Specified by:
      getClusterEndpoint in class DatabaseClusterBase
    • getClusterIdentifier

      @Stability(Stable) @NotNull public String getClusterIdentifier()
      Identifier of the cluster.
      Specified by:
      getClusterIdentifier in interface IDatabaseCluster
      Specified by:
      getClusterIdentifier in class DatabaseClusterBase
    • getClusterReadEndpoint

      @Stability(Stable) @NotNull public Endpoint getClusterReadEndpoint()
      Endpoint to use for load-balanced read-only operations.
      Specified by:
      getClusterReadEndpoint in interface IDatabaseCluster
      Specified by:
      getClusterReadEndpoint in class DatabaseClusterBase
    • getClusterResourceIdentifier

      @Stability(Stable) @NotNull public String getClusterResourceIdentifier()
      The immutable identifier for the cluster; for example: cluster-ABCD1234EFGH5678IJKL90MNOP.

      This AWS Region-unique identifier is used in things like IAM authentication policies.

      Specified by:
      getClusterResourceIdentifier in interface IDatabaseCluster
      Specified by:
      getClusterResourceIdentifier in class DatabaseClusterBase
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      Access to the network connections.
      Specified by:
      getConnections in interface IConnectable
      Specified by:
      getConnections in class DatabaseClusterBase
    • getInstanceEndpoints

      @Stability(Stable) @NotNull public List<Endpoint> getInstanceEndpoints()
      Endpoints which address each individual replica.
      Specified by:
      getInstanceEndpoints in interface IDatabaseCluster
      Specified by:
      getInstanceEndpoints in class DatabaseClusterBase
    • getInstanceIdentifiers

      @Stability(Stable) @NotNull public List<String> getInstanceIdentifiers()
      Identifiers of the replicas.
      Specified by:
      getInstanceIdentifiers in interface IDatabaseCluster
      Specified by:
      getInstanceIdentifiers in class DatabaseClusterBase
    • getMultiUserRotationApplication

      @Stability(Stable) @NotNull public SecretRotationApplication getMultiUserRotationApplication()
      Application for multi user rotation to this cluster.
    • getNewCfnProps

      @Stability(Stable) @NotNull protected CfnDBClusterProps getNewCfnProps()
    • getSecurityGroups

      @Stability(Stable) @NotNull protected List<ISecurityGroup> getSecurityGroups()
    • getServerlessV2MaxCapacity

      @Stability(Stable) @NotNull protected Number getServerlessV2MaxCapacity()
    • getServerlessV2MinCapacity

      @Stability(Stable) @NotNull protected Number getServerlessV2MinCapacity()
    • getSingleUserRotationApplication

      @Stability(Stable) @NotNull public SecretRotationApplication getSingleUserRotationApplication()
      Application for single user rotation of the master password to this cluster.
    • getSubnetGroup

      @Stability(Stable) @NotNull protected ISubnetGroup getSubnetGroup()
    • getVpc

      @Stability(Stable) @NotNull public IVpc getVpc()
      The VPC network to place the cluster in.
    • getEngine

      @Stability(Stable) @Nullable public IClusterEngine getEngine()
      The engine for this Cluster.

      Never undefined.

      Specified by:
      getEngine in interface IDatabaseCluster
      Specified by:
      getEngine in class DatabaseClusterBase
    • getSecret

      @Stability(Stable) @Nullable public ISecret getSecret()
      The secret attached to this cluster.
      Specified by:
      getSecret in class DatabaseClusterBase
    • getVpcSubnets

      @Stability(Stable) @Nullable public SubnetSelection getVpcSubnets()
      The cluster's subnets.
    • getEnableDataApi

      @Stability(Stable) @Nullable protected Boolean getEnableDataApi()
      Specified by:
      getEnableDataApi in class DatabaseClusterBase
    • setEnableDataApi

      @Stability(Stable) protected void setEnableDataApi(@Nullable Boolean value)
      Specified by:
      setEnableDataApi in class DatabaseClusterBase
    • getHasServerlessInstance

      @Stability(Stable) @Nullable protected Boolean getHasServerlessInstance()
    • setHasServerlessInstance

      @Stability(Stable) protected void setHasServerlessInstance(@Nullable Boolean value)