Provides an DocumentDB Cluster Resource Instance. A Cluster Instance Resource defines attributes that are specific to a single instance in a DocumentDB Cluster.
You do not designate a primary and subsequent replicas. Instead, you simply add DocumentDB
Instances and DocumentDB manages the replication. You can use the count
meta-parameter to make multiple instances and join them all to the same DocumentDB
Cluster, or you may specify different Cluster Instance resources with various
instance_class
sizes.
resource "aws_docdb_cluster_instance" "cluster_instances" {
count = 2
identifier = "docdb-cluster-demo-${count.index}"
cluster_identifier = aws_docdb_cluster.default.id
instance_class = "db.r5.large"
}
resource "aws_docdb_cluster" "default" {
cluster_identifier = "docdb-cluster-demo"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
master_username = "foo"
master_password = "barbut8chars"
}
For more detailed documentation about each argument, refer to the AWS official documentation.
This argument supports the following arguments:
apply_immediately
- (Optional) Specifies whether any database modifications
are applied immediately, or during the next maintenance window. Default isfalse
.auto_minor_version_upgrade
- (Optional) This parameter does not apply to Amazon DocumentDB. Amazon DocumentDB does not perform minor version upgrades regardless of the value set (see docs). Default true
.availability_zone
- (Optional, Computed) The EC2 Availability Zone that the DB instance is created in. See docs about the details.ca_cert_identifier
- (Optional) The identifier of the certificate authority (CA) certificate for the DB instance.cluster_identifier
- (Required) The identifier of the aws_docdb_cluster
in which to launch this instance.copy_tags_to_snapshot
– (Optional, boolean) Copy all DB instance tags
to snapshots. Default is false
.enable_performance_insights
- (Optional) A value that indicates whether to enable Performance Insights for the DB Instance. Default false
. See [docs] (https://docs.aws.amazon.com/documentdb/latest/developerguide/performance-insights.html) about the details.engine
- (Optional) The name of the database engine to be used for the DocumentDB instance. Defaults to docdb
. Valid Values: docdb
.identifier
- (Optional, Forces new resource) The identifier for the DocumentDB instance, if omitted, Terraform will assign a random, unique identifier.identifier_prefix
- (Optional, Forces new resource) Creates a unique identifier beginning with the specified prefix. Conflicts with identifier
.instance_class
- (Required) The instance class to use. For details on CPU and memory, see Scaling for DocumentDB Instances.
DocumentDB currently supports the below instance classes.
Please see AWS Documentation for complete details.
performance_insights_kms_key_id
- (Optional) The KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. If you do not specify a value for PerformanceInsightsKMSKeyId, then Amazon DocumentDB uses your default KMS key.preferred_maintenance_window
- (Optional) The window to perform maintenance in.
Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00".promotion_tier
- (Optional) Default 0. Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoter to writer.tags
- (Optional) A map of tags to assign to the instance. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.This resource exports the following attributes in addition to the arguments above:
arn
- Amazon Resource Name (ARN) of cluster instancedb_subnet_group_name
- The DB subnet group to associate with this DB instance.dbi_resource_id
- The region-unique, immutable identifier for the DB instance.endpoint
- The DNS address for this instance. May not be writableengine_version
- The database engine versionkms_key_id
- The ARN for the KMS encryption key if one is set to the cluster.port
- The database portpreferred_backup_window
- The daily time range during which automated backups are created if automated backups are enabled.storage_encrypted
- Specifies whether the DB cluster is encrypted.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.writer
– Boolean indicating if this instance is writable. False
indicates this instance is a read replica.create
- (Default 90m
)
restoring from Snapshotsupdate
- (Default 90m
)delete
- (Default 90m
)
the time required to take snapshotsIn Terraform v1.5.0 and later, use an import
block to import DocumentDB Cluster Instances using the identifier
. For example:
import {
to = aws_docdb_cluster_instance.prod_instance_1
id = "aurora-cluster-instance-1"
}
Using terraform import
, import DocumentDB Cluster Instances using the identifier
. For example:
% terraform import aws_docdb_cluster_instance.prod_instance_1 aurora-cluster-instance-1