Class DatabaseCluster

All Implemented Interfaces:
IConstruct, IDependable, IResource, IDatabaseCluster, IConnectable, ISecretAttachmentTarget,, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:41.906Z") @Stability(Stable) public class DatabaseCluster extends Resource implements IDatabaseCluster
Create a clustered database with a given number of instances.


 Vpc vpc;
 DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Database")
                 .username("myuser") // NOTE: 'admin' is reserved by DocumentDB
                 .excludeCharacters("\"@/:") // optional, defaults to the set "\"@/" and is also used for eventually created rotations
         .instanceType(InstanceType.of(InstanceClass.R5, InstanceSize.LARGE))
  • Field Details


      @Stability(Stable) public static final Number DEFAULT_NUM_INSTANCES
      The default number of instances in the DocDB cluster if none are specified.

      @Stability(Stable) public static final Number DEFAULT_PORT
      The default port Document DB listens on.
  • Constructor Details

    • DatabaseCluster

      protected DatabaseCluster( objRef)
    • DatabaseCluster

      protected DatabaseCluster( initializationMode)
    • DatabaseCluster

      @Stability(Stable) public DatabaseCluster(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DatabaseClusterProps props)
      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.

      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.

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

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

      automaticallyAfter - Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation.
    • addRotationSingleUser

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

      @Stability(Stable) public void addSecurityGroups(@NotNull @NotNull ISecurityGroup... securityGroups)
      Adds security groups to this cluster.

      securityGroups - The security groups to add. This parameter is required.
    • asSecretAttachmentTarget

      @Stability(Stable) @NotNull public SecretAttachmentTargetProps asSecretAttachmentTarget()
      Renders the secret attachment target specifications.
      Specified by:
      asSecretAttachmentTarget in interface ISecretAttachmentTarget
    • getClusterEndpoint

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

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

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

      @Stability(Stable) @NotNull public String getClusterResourceIdentifier()
      The resource id for the cluster;

      for example: cluster-ABCD1234EFGH5678IJKL90MNOP. The cluster ID uniquely identifies the cluster and is used in things like IAM authentication policies.

    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      The connections object to implement IConnectable.
      Specified by:
      getConnections in interface IConnectable
    • getInstanceEndpoints

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

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

      @Stability(Stable) @NotNull public String getSecurityGroupId()
      Security group identifier of this database.
      Specified by:
      getSecurityGroupId in interface IDatabaseCluster
    • getSecret

      @Stability(Stable) @Nullable public ISecret getSecret()
      The secret attached to this cluster.