Class DatabaseCluster

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

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-11T15:55:56.220Z") @Stability(Stable) public class DatabaseCluster extends Resource implements IDatabaseCluster
Create a clustered database with a given number of instances.

Example:

 Vpc vpc;
 DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Database")
         .masterUser(Login.builder()
                 .username("myuser")
                 .build())
         .instanceType(InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE))
         .vpcSubnets(SubnetSelection.builder()
                 .subnetType(SubnetType.PUBLIC)
                 .build())
         .vpc(vpc)
         .removalPolicy(RemovalPolicy.SNAPSHOT)
         .build();
 
  • Field Details

    • DEFAULT_NUM_INSTANCES

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

      @Stability(Stable) public static final Number DEFAULT_PORT
      The default port Document DB listens on.
  • 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.

      Parameters:
      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.

      Parameters:
      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.

      Parameters:
      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.