DatabaseCluster

class aws_cdk.aws_docdb.DatabaseCluster(scope, id, *, instance_props, master_user, backup=None, db_cluster_name=None, engine_version=None, instance_identifier_base=None, instances=None, kms_key=None, parameter_group=None, port=None, preferred_maintenance_window=None, removal_policy=None, storage_encrypted=None)

Bases: aws_cdk.core.Resource

Create a clustered database with a given number of instances.

stability :stability: experimental resource: :resource:: AWS::DocDB::DBCluster

__init__(scope, id, *, instance_props, master_user, backup=None, db_cluster_name=None, engine_version=None, instance_identifier_base=None, instances=None, kms_key=None, parameter_group=None, port=None, preferred_maintenance_window=None, removal_policy=None, storage_encrypted=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • instance_props (InstanceProps) – Settings for the individual instances that are launched.

  • master_user (Login) – Username and password for the administrative user.

  • backup (Optional[BackupProps]) – Backup settings. Default: - Backup retention period for automated backups is 1 day. Backup preferred window is set to a 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.

  • db_cluster_name (Optional[str]) – An optional identifier for the cluster. Default: - A name is automatically generated.

  • engine_version (Optional[str]) – What version of the database to start. Default: - The default engine version.

  • instance_identifier_base (Optional[str]) – Base identifier for instances. Every replica is named by appending the replica number to this string, 1-based. Default: - dbClusterName is used with the word “Instance” appended. If dbClusterName is not provided, the identifier is automatically generated.

  • instances (Union[int, float, None]) – Number of DocDB compute instances. Default: 1

  • kms_key (Optional[IKey]) – The KMS key for storage encryption. Default: - default master key.

  • parameter_group (Optional[IClusterParameterGroup]) – Additional parameters to pass to the database engine. Default: - No parameter group.

  • port (Union[int, float, None]) – The port the DocumentDB cluster will listen on. Default: DatabaseCluster.DEFAULT_PORT

  • preferred_maintenance_window (Optional[str]) – A weekly time range in which maintenance should preferably execute. Must be at least 30 minutes long. Example: ‘tue:04:17-tue:04:47’ 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.

  • removal_policy (Optional[RemovalPolicy]) – The removal policy to apply when the cluster and its instances are removed or replaced during a stack update, or when the stack is deleted. This removal policy also applies to the implicit security group created for the cluster if one is not supplied as a parameter. Default: - Retain cluster.

  • storage_encrypted (Optional[bool]) – Whether to enable storage encryption. Default: true

stability :stability: experimental

Return type

None

Methods

add_rotation_multi_user(id, *, secret, automatically_after=None)

Adds the multi user rotation to this cluster.

Parameters
  • id (str) –

  • secret (ISecret) – The secret to rotate. It must be a JSON string with the following format:: { “engine”: <required: must be set to ‘mongo’>, “host”: <required: instance host name>, “username”: <required: username>, “password”: <required: password>, “dbname”: <optional: database name>, “port”: <optional: if not specified, default port 27017 will be used>, “masterarn”: <required: the arn of the master secret which will be used to create users/change passwords> “ssl”: <optional: if not specified, defaults to false. This must be true if being used for DocumentDB rotations where the cluster has TLS enabled> }

  • automatically_after (Optional[Duration]) – Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation. Default: Duration.days(30)

stability :stability: experimental

Return type

SecretRotation

add_rotation_single_user(automatically_after=None)

Adds the single user rotation of the master password to this cluster.

Parameters

automatically_after (Optional[Duration]) – Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation.

stability :stability: experimental

Return type

SecretRotation

as_secret_attachment_target()

Renders the secret attachment target specifications.

stability :stability: experimental

Return type

SecretAttachmentTargetProps

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

DEFAULT_NUM_INSTANCES = 1
DEFAULT_PORT = 27017
cluster_endpoint

The endpoint to use for read/write operations.

stability :stability: experimental

Return type

Endpoint

cluster_identifier

Identifier of the cluster.

stability :stability: experimental

Return type

str

cluster_read_endpoint

Endpoint to use for load-balanced read-only operations.

stability :stability: experimental

Return type

Endpoint

cluster_resource_identifier

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.

stability :stability: experimental attribute: :attribute:: ClusterResourceId

Return type

str

connections

The connections object to implement IConectable.

stability :stability: experimental

Return type

Connections

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

Return type

ResourceEnvironment

instance_endpoints

Endpoints which address each individual replica.

stability :stability: experimental

Return type

List[Endpoint]

instance_identifiers

Identifiers of the replicas.

stability :stability: experimental

Return type

List[str]

node

The construct tree node associated with this construct.

Return type

ConstructNode

secret

The secret attached to this cluster.

stability :stability: experimental

Return type

Optional[ISecret]

security_group_id

Security group identifier of this database.

stability :stability: experimental

Return type

str

stack

The stack in which this resource is defined.

Return type

Stack

Static Methods

classmethod from_database_cluster_attributes(scope, id, *, cluster_endpoint_address, cluster_identifier, instance_endpoint_addresses, instance_identifiers, port, reader_endpoint_address, security_group)

Import an existing DatabaseCluster from properties.

Parameters
  • scope (Construct) –

  • id (str) –

  • cluster_endpoint_address (str) – Cluster endpoint address.

  • cluster_identifier (str) – Identifier for the cluster.

  • instance_endpoint_addresses (List[str]) – Endpoint addresses of individual instances.

  • instance_identifiers (List[str]) – Identifier for the instances.

  • port (Union[int, float]) – The database port.

  • reader_endpoint_address (str) – Reader endpoint address.

  • security_group (ISecurityGroup) – The security group of the database cluster.

stability :stability: experimental

Return type

IDatabaseCluster

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool