Provides an RDS Cluster Resource Instance. A Cluster Instance Resource defines attributes that are specific to a single instance in a RDS Cluster, specifically running Amazon Aurora.

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

For more information on Amazon Aurora, see Aurora on Amazon RDS in the Amazon RDS User Guide.

Example Usage

resource "aws_rds_cluster_instance" "cluster_instances" {
  count              = 2
  identifier         = "aurora-cluster-demo-${count.index}"
  cluster_identifier = "${}"
  instance_class     = "db.r3.large"

resource "aws_rds_cluster" "default" {
  cluster_identifier = "aurora-cluster-demo"
  availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]
  database_name      = "mydb"
  master_username    = "foo"
  master_password    = "barbut8chars"

Argument Reference

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

The following arguments are supported:

  • identifier - (Optional) The Instance Identifier. Must be a lower case string. If omitted, a unique identifier will be generated.
  • cluster_identifier - (Required) The identifier of the aws_rds_cluster in which to launch this instance.
  • instance_class - (Required) The instance class to use. For details on CPU and memory, see Scaling Aurora DB Instances. Aurora currently supports the below instance classes.
    • db.r3.large
    • db.r3.xlarge
    • db.r3.2xlarge
    • db.r3.4xlarge
    • db.r3.8xlarge
  • publicly_accessible - (Optional) Bool to control if instance is publicly accessible. Default false. See the documentation on Creating DB Instances for more details on controlling this property.
  • db_subnet_group_name - (Required if publicly_accessible = false, Optional otherwise) A DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name of the attached aws_rds_cluster.
  • db_parameter_group_name - (Optional) The name of the DB parameter group to associate with this instance.
  • apply_immediately - (Optional) Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default isfalse.
  • storage_encrypted - (Optional) Specifies whether the DB cluster instance is encrypted. The default is false if not specified.
  • monitoring_role_arn - (Optional) The ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch Logs. You can find more information on the AWS Documentation what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances.
  • monitoring_interval - (Optional) The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60.
  • 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
  • kms_key_id - (Optional) The ARN for the KMS encryption key. When specifying kms_key_id, storage_encrypted needs to be set to true
  • tags - (Optional) A mapping of tags to assign to the instance.

Attributes Reference

The following attributes are exported:

  • cluster_identifier - The RDS Cluster Identifier
  • identifier - The Instance identifier
  • id - The Instance identifier
  • writer – Boolean indicating if this instance is writable. False indicates this instance is a read replica
  • allocated_storage - The amount of allocated storage
  • availability_zones - The availability zone of the instance
  • endpoint - The DNS address for this instance. May not be writable
  • engine - The database engine
  • engine_version - The database engine version
  • database_name - The database name
  • port - The database port
  • status - The RDS instance status


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

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