Skip to content

Resource: awsDocdbClusterInstance

Provides an DocDB Cluster Resource Instance. A Cluster Instance Resource defines attributes that are specific to a single instance in a DocDB Cluster.

You do not designate a primary and subsequent replicas. Instead, you simply add DocDB Instances and DocDB manages the replication. You can use the count meta-parameter to make multiple instances and join them all to the same DocDB Cluster, or you may specify different Cluster Instance resources with various instanceClass sizes.

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";
const awsDocdbClusterDefault = new aws.docdbCluster.DocdbCluster(
  this,
  "default",
  {
    availabilityZones: ["us-west-2a", "us-west-2b", "us-west-2c"],
    clusterIdentifier: "docdb-cluster-demo",
    masterPassword: "barbut8chars",
    masterUsername: "foo",
  }
);
const awsDocdbClusterInstanceClusterInstances =
  new aws.docdbClusterInstance.DocdbClusterInstance(this, "cluster_instances", {
    clusterIdentifier: awsDocdbClusterDefault.id,
    identifier: "docdb-cluster-demo-${count.index}",
    instanceClass: "db.r5.large",
  });
/*In most cases loops should be handled in the programming language context and 
not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
you need to keep this like it is.*/
awsDocdbClusterInstanceClusterInstances.addOverride("count", 2);

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 database modifications are applied immediately, or during the next maintenance window. Default isfalse.
  • autoMinorVersionUpgrade - (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.
  • availabilityZone - (Optional, Computed) The EC2 Availability Zone that the DB instance is created in. See docs about the details.
  • clusterIdentifier - (Required) The identifier of the awsDocdbCluster in which to launch this instance.
  • enablePerformanceInsights - (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 DocDB instance. Defaults to docdb. Valid Values: docdb.
  • identifier - (Optional, Forces new resource) The identifier for the DocDB instance, if omitted, Terraform will assign a random, unique identifier.
  • identifierPrefix - (Optional, Forces new resource) Creates a unique identifier beginning with the specified prefix. Conflicts with identifier.
  • instanceClass - (Required) The instance class to use. For details on CPU and memory, see Scaling for DocDB Instances. DocDB currently supports the below instance classes. Please see AWS Documentation for complete details.
  • db.r5.large
  • db.r5.xlarge
  • db.r5.2xlarge
  • db.r5.4xlarge
  • db.r5.12xlarge
  • db.r5.24xlarge
  • db.r4.large
  • db.r4.xlarge
  • db.r4.2xlarge
  • db.r4.4xlarge
  • db.r4.8xlarge
  • db.r4.16xlarge
  • db.t3.medium
  • performanceInsightsKmsKeyId - (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.
  • preferredMaintenanceWindow - (Optional) The window to perform maintenance in. Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00".
  • promotionTier - (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 defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Attributes Reference

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

  • arn - Amazon Resource Name (ARN) of cluster instance
  • dbSubnetGroupName - The DB subnet group to associate with this DB instance.
  • dbiResourceId - The region-unique, immutable identifier for the DB instance.
  • endpoint - The DNS address for this instance. May not be writable
  • engineVersion - The database engine version
  • kmsKeyId - The ARN for the KMS encryption key if one is set to the cluster.
  • port - The database port
  • preferredBackupWindow - The daily time range during which automated backups are created if automated backups are enabled.
  • storageEncrypted - Specifies whether the DB cluster is encrypted.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
  • writer – Boolean indicating if this instance is writable. false indicates this instance is a read replica.
  • caCertIdentifier - (Optional) The identifier of the CA certificate for the DB instance.

Timeouts

Configuration options:

  • create - (Default 90M) restoring from Snapshots
  • update - (Default 90M)
  • delete - (Default 90M) the time required to take snapshots

Import

DocDB Cluster Instances can be imported using the identifier, e.g.,

$ terraform import aws_docdb_cluster_instance.prod_instance_1 aurora-cluster-instance-1