Skip to content

Resource: awsDocdbCluster

Manages a DocDB Cluster.

Changes to a DocDB Cluster can occur when you manually change a parameter, such as port, and are reflected in the next maintenance window. Because of this, Terraform may report a difference in its planning phase because a modification has not yet taken place. You can use the applyImmediately flag to instruct the service to apply the change immediately (see documentation below).

\~> Note: using applyImmediately can result in a brief downtime as the server reboots. \~> Note: All arguments including the username and password will be stored in the raw state as plain-text. Read more about sensitive data in state.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.docdbCluster.DocdbCluster(this, "docdb", {
  backupRetentionPeriod: 5,
  clusterIdentifier: "my-docdb-cluster",
  engine: "docdb",
  masterPassword: "mustbeeightchars",
  masterUsername: "foo",
  preferredBackupWindow: "07:00-09:00",
  skipFinalSnapshot: true,
});

Argument Reference

For more detailed documentation about each argument, refer to the AWS official documentation.

The following arguments are supported:

  • applyImmediately - (Optional) Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is false.
  • availabilityZones - (Optional) A list of EC2 Availability Zones that instances in the DB cluster can be created in.
  • backupRetentionPeriod - (Optional) The days to retain backups for. Default 1
  • clusterIdentifierPrefix - (Optional, Forces new resource) Creates a unique cluster identifier beginning with the specified prefix. Conflicts with clusterIdentifier.
  • clusterIdentifier - (Optional, Forces new resources) The cluster identifier. If omitted, Terraform will assign a random, unique identifier.
  • dbSubnetGroupName - (Optional) A DB subnet group to associate with this DB instance.
  • dbClusterParameterGroupName - (Optional) A cluster parameter group to associate with the cluster.
  • deletionProtection - (Optional) A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled. By default, deletion protection is disabled.
  • enabledCloudwatchLogsExports - (Optional) List of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, profiler.
  • engineVersion - (Optional) The database engine version. Updating this argument results in an outage.
  • engine - (Optional) The name of the database engine to be used for this DB cluster. Defaults to docdb. Valid Values: docdb
  • finalSnapshotIdentifier - (Optional) The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made.
  • globalClusterIdentifier - (Optional) The global cluster identifier specified on awsDocdbGlobalCluster.
  • kmsKeyId - (Optional) The ARN for the KMS encryption key. When specifying kmsKeyId, storageEncrypted needs to be set to true.
  • masterPassword - (Required unless a snapshotIdentifier or unless a globalClusterIdentifier is provided when the cluster is the "secondary" cluster of a global database) Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Please refer to the DocDB Naming Constraints.
  • masterUsername - (Required unless a snapshotIdentifier or unless a globalClusterIdentifier is provided when the cluster is the "secondary" cluster of a global database) Username for the master DB user.
  • port - (Optional) The port on which the DB accepts connections
  • preferredBackupWindow - (Optional) The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter.Time in UTC Default: A 30-minute window selected at random from an 8-hour block of time per regionE.g., 04:00-09:00
  • preferredMaintenanceWindow - (Optional) The weekly time range during which system maintenance can occur, in (UTC) e.g., wed:04:00-wed:04:30
  • skipFinalSnapshot - (Optional) Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from finalSnapshotIdentifier. Default is false.
  • snapshotIdentifier - (Optional) Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot.
  • storageEncrypted - (Optional) Specifies whether the DB cluster is encrypted. The default is false.
  • tags - (Optional) A map of tags to assign to the DB cluster. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
  • vpcSecurityGroupIds - (Optional) List of VPC security groups to associate with the Cluster

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • arn - Amazon Resource Name (ARN) of cluster
  • clusterMembers – List of DocDB Instances that are a part of this cluster
  • clusterResourceId - The DocDB Cluster Resource ID
  • endpoint - The DNS address of the DocDB instance
  • hostedZoneId - The Route53 Hosted Zone ID of the endpoint
  • id - The DocDB Cluster Identifier
  • readerEndpoint - A read-only endpoint for the DocDB cluster, automatically load-balanced across replicas
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Timeouts

Configuration options:

  • create - (Default 120M)
  • update - (Default 120M)
  • delete - (Default 120M) any cleanup task during the destroying process.

Import

DocDB Clusters can be imported using the clusterIdentifier, e.g.,

$ terraform import aws_docdb_cluster.docdb_cluster docdb-prod-cluster