Manages a DocumentDB Cluster.
Changes to a DocumentDB 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
apply_immediately
flag to instruct the service to apply the change immediately
(see documentation below).
resource "aws_docdb_cluster" "docdb" {
cluster_identifier = "my-docdb-cluster"
engine = "docdb"
master_username = "foo"
master_password = "mustbeeightchars"
backup_retention_period = 5
preferred_backup_window = "07:00-09:00"
skip_final_snapshot = true
}
For more detailed documentation about each argument, refer to the AWS official documentation.
This argument supports the following arguments:
allow_major_version_upgrade
- (Optional) A value that indicates whether major version upgrades are allowed. Constraints: You must allow major version upgrades when specifying a value for the EngineVersion parameter that is a different major version than the DB cluster's current version.apply_immediately
- (Optional) Specifies whether any cluster modifications
are applied immediately, or during the next maintenance window. Default is
false
.availability_zones
- (Optional) A list of EC2 Availability Zones that
instances in the DB cluster can be created in.backup_retention_period
- (Optional) The days to retain backups for. Default 1
cluster_identifier_prefix
- (Optional, Forces new resource) Creates a unique cluster identifier beginning with the specified prefix. Conflicts with cluster_identifier
.cluster_identifier
- (Optional, Forces new resources) The cluster identifier. If omitted, Terraform will assign a random, unique identifier.db_subnet_group_name
- (Optional) A DB subnet group to associate with this DB instance.db_cluster_parameter_group_name
- (Optional) A cluster parameter group to associate with the cluster.deletion_protection
- (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.enabled_cloudwatch_logs_exports
- (Optional) List of log types to export to cloudwatch. If omitted, no logs will be exported.
The following log types are supported: audit
, profiler
.engine_version
- (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
.final_snapshot_identifier
- (Optional) The name of your final DB snapshot
when this DB cluster is deleted. If omitted, no final snapshot will be
made.global_cluster_identifier
- (Optional) The global cluster identifier specified on aws_docdb_global_cluster
.kms_key_id
- (Optional) The ARN for the KMS encryption key. When specifying kms_key_id
, storage_encrypted
needs to be set to true.master_password
- (Required unless a snapshot_identifier
or unless a global_cluster_identifier
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 DocumentDB Naming Constraints.master_username
- (Required unless a snapshot_identifier
or unless a global_cluster_identifier
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 connectionspreferred_backup_window
- (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:00preferred_maintenance_window
- (Optional) The weekly time range during which system maintenance can occur, in (UTC) e.g., wed:04:00-wed:04:30skip_final_snapshot
- (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 final_snapshot_identifier
. Default is false
.snapshot_identifier
- (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. Automated snapshots should not be used for this attribute, unless from a different cluster. Automated snapshots are deleted as part of cluster destruction when the resource is replaced.storage_encrypted
- (Optional) Specifies whether the DB cluster is encrypted. The default is false
.storage_type
- (Optional) The storage type to associate with the DB cluster. Valid values: standard
, iopt1
.tags
- (Optional) A map of tags to assign to the DB cluster. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.vpc_security_group_ids
- (Optional) List of VPC security groups to associate
with the ClusterThis resource exports the following attributes in addition to the arguments above:
arn
- Amazon Resource Name (ARN) of clustercluster_members
– List of DocumentDB Instances that are a part of this clustercluster_resource_id
- The DocumentDB Cluster Resource IDendpoint
- The DNS address of the DocumentDB instancehosted_zone_id
- The Route53 Hosted Zone ID of the endpointid
- The DocumentDB Cluster Identifierreader_endpoint
- A read-only endpoint for the DocumentDB cluster, automatically load-balanced across replicastags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.create
- (Default 120m
)update
- (Default 120m
)delete
- (Default 120m
)
any cleanup task during the destroying process.In Terraform v1.5.0 and later, use an import
block to import DocumentDB Clusters using the cluster_identifier
. For example:
import {
to = aws_docdb_cluster.docdb_cluster
id = "docdb-prod-cluster"
}
Using terraform import
, import DocumentDB Clusters using the cluster_identifier
. For example:
% terraform import aws_docdb_cluster.docdb_cluster docdb-prod-cluster