Provides an RDS Cluster Instance Resource. 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.
resource "aws_rds_cluster_instance" "cluster_instances" {
count = 2
identifier = "aurora-cluster-demo-${count.index}"
cluster_identifier = aws_rds_cluster.default.id
instance_class = "db.r4.large"
engine = aws_rds_cluster.default.engine
engine_version = aws_rds_cluster.default.engine_version
}
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"
}
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) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Default true
.availability_zone
- (Optional, Computed, Forces new resource) EC2 Availability Zone that the DB instance is created in. See docs about the details.ca_cert_identifier
- (Optional) Identifier of the CA certificate for the DB instance.cluster_identifier
- (Required, Forces new resource) Identifier of the aws_rds_cluster
in which to launch this instance.copy_tags_to_snapshot
– (Optional, boolean) Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. Default false
.custom_iam_instance_profile
- (Optional) Instance profile associated with the underlying Amazon EC2 instance of an RDS Custom DB instance.db_parameter_group_name
- (Optional) Name of the DB parameter group to associate with this instance.db_subnet_group_name
- (Required if publicly_accessible = false
, Optional otherwise, Forces new resource) DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name
of the attached aws_rds_cluster
.engine_version
- (Optional) Database engine version. Please note that to upgrade the engine_version
of the instance, it must be done on the aws_rds_cluster
engine_version
. Trying to upgrade in aws_cluster_instance
will not update the engine_version
.engine
- (Required, Forces new resource) Name of the database engine to be used for the RDS cluster instance.
Valid Values: aurora-mysql
, aurora-postgresql
, mysql
, postgres
.(Note that mysql
and postgres
are Multi-AZ RDS clusters).identifier_prefix
- (Optional, Forces new resource) Creates a unique identifier beginning with the specified prefix. Conflicts with identifier
.identifier
- (Optional, Forces new resource) Identifier for the RDS instance, if omitted, Terraform will assign a random, unique identifier.instance_class
- (Required) Instance class to use. For details on CPU and memory, see Scaling Aurora DB Instances. Aurora uses db.*
instance classes/types. Please see AWS Documentation for currently available instance classes and complete details.monitoring_interval
- (Optional) 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.monitoring_role_arn
- (Optional) 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.performance_insights_enabled
- (Optional) Specifies whether Performance Insights is enabled or not.performance_insights_kms_key_id
- (Optional) ARN for the KMS key to encrypt Performance Insights data. When specifying performance_insights_kms_key_id
, performance_insights_enabled
needs to be set to true.performance_insights_retention_period
- (Optional) Amount of time in days to retain Performance Insights data. Valid values are 7
, 731
(2 years) or a multiple of 31
. When specifying performance_insights_retention_period
, performance_insights_enabled
needs to be set to true. Defaults to '7'.preferred_backup_window
- (Optional) Daily time range during which automated backups are created if automated backups are enabled. Eg: "04:00-09:00". NOTE: If preferred_backup_window
is set at the cluster level, this argument must be omitted.preferred_maintenance_window
- (Optional) 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 promoted to writer.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.tags
- (Optional) 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 instancecluster_identifier
- RDS Cluster Identifieridentifier
- Instance identifierid
- Instance identifierwriter
– Boolean indicating if this instance is writable. False
indicates this instance is a read replica.availability_zone
- Availability zone of the instanceendpoint
- DNS address for this instance. May not be writableengine
- Database engineengine_version_actual
- Database engine versionport
- Database portstorage_encrypted
- Specifies whether the DB cluster is encrypted.kms_key_id
- ARN for the KMS encryption key if one is set to the cluster.network_type
- Network type of the DB instance.dbi_resource_id
- Region-unique, immutable identifier for the DB instance.performance_insights_enabled
- Specifies whether Performance Insights is enabled or not.performance_insights_kms_key_id
- ARN for the KMS encryption key used by Performance Insights.tags_all
- Map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.create
- (Default 90m
)update
- (Default 90m
)delete
- (Default 90m
)In Terraform v1.5.0 and later, use an import
block to import RDS Cluster Instances using the identifier
. For example:
import {
to = aws_rds_cluster_instance.prod_instance_1
id = "aurora-cluster-instance-1"
}
Using terraform import
, import RDS Cluster Instances using the identifier
. For example:
% terraform import aws_rds_cluster_instance.prod_instance_1 aurora-cluster-instance-1