2015-08-04 23:24:55 +02:00
---
layout: "aws"
page_title: "AWS: aws_rds_cluster"
sidebar_current: "docs-aws-resource-rds-cluster"
description: |-
Provides an RDS Cluster Resource
---
# aws\_rds\_cluster
Provides an RDS Cluster Resource. A Cluster Resource defines attributes that are
applied to the entire cluster of [RDS Cluster Instances][3]. Use the RDS Cluster
resource and RDS Cluster Instances to create and use Amazon Aurora, a MySQL-compatible
database engine.
For more information on Amazon Aurora, see [Aurora on Amazon RDS][2] in the Amazon RDS User Guide.
2015-12-18 18:22:21 +01:00
Changes to a RDS 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 it's planning
phase because a modification has not yet taken place. You can use the
2016-07-21 20:55:10 +02:00
`apply_immediately` flag to instruct the service to apply the change immediately
(see documentation below).
2015-12-18 18:22:21 +01:00
2016-07-21 20:55:10 +02:00
~> **Note:** using `apply_immediately` can result in a
brief downtime as the server reboots. See the AWS Docs on [RDS Maintenance][4]
2015-12-18 18:22:21 +01:00
for more information.
2015-08-04 23:24:55 +02:00
## Example Usage
```
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 = "bar"
2015-11-04 20:40:22 +01:00
backup_retention_period = 5
preferred_backup_window = "07:00-09:00"
2015-08-04 23:24:55 +02:00
}
```
~> **NOTE:** RDS Clusters resources that are created without any matching
RDS Cluster Instances do not currently display in the AWS Console.
## Argument Reference
For more detailed documentation about each argument, refer to
2016-01-14 21:55:39 +01:00
the [AWS official documentation ](https://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/CLIReference-cmd-ModifyDBInstance.html ).
2015-08-04 23:24:55 +02:00
The following arguments are supported:
* `cluster_identifier` - (Required) The Cluster Identifier. Must be a lower case
string.
* `database_name` - (Optional) The name for your database of up to 8 alpha-numeric
characters. If you do not provide a name, Amazon RDS will not create a
database in the DB cluster you are creating
2016-06-29 10:02:26 +02:00
* `master_password` - (Required unless a `snapshot_identifier` is provided) Password for the master DB user. Note that this may
2015-08-04 23:24:55 +02:00
show up in logs, and it will be stored in the state file
2016-06-29 10:02:26 +02:00
* `master_username` - (Required unless a `snapshot_identifier` is provided) Username for the master DB user
2015-10-07 18:04:34 +02:00
* `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.
2016-07-28 01:26:47 +02:00
* `skip_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 true.
2015-08-04 23:24:55 +02:00
* `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
2016-07-21 20:55:10 +02:00
* `preferred_backup_window` - (Optional) The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter.
2015-11-04 20:40:22 +01:00
Default: A 30-minute window selected at random from an 8-hour block of time per region. e.g. 04:00-09:00
* `preferred_maintenance_window` - (Optional) The weekly time range during which system maintenance can occur, in (UTC) e.g. wed:04:00-wed:04:30
2015-08-04 23:24:55 +02:00
* `port` - (Optional) The port on which the DB accepts connections
* `vpc_security_group_ids` - (Optional) List of VPC security groups to associate
with the Cluster
2016-06-29 10:02:26 +02:00
* `snapshot_identifier` - (Optional) Specifies whether or not to create this cluster from a snapshot. This correlates to the snapshot ID you'd find in the RDS console, e.g: rds:production-2015-06-26-06-05.
2016-03-08 22:51:16 +01:00
* `storage_encrypted` - (Optional) Specifies whether the DB cluster is encrypted. The default is `false` if not specified.
2015-08-04 23:24:55 +02:00
* `apply_immediately` - (Optional) Specifies whether any cluster modifications
are applied immediately, or during the next maintenance window. Default is
2016-01-14 21:55:39 +01:00
`false` . See [Amazon RDS Documentation for more information. ](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html )
2016-03-18 23:12:57 +01:00
* `db_subnet_group_name` - (Optional) A DB subnet group to associate with this DB instance. **NOTE:** This must match the `db_subnet_group_name` specified on every [`aws_rds_cluster_instance` ](/docs/providers/aws/r/rds_cluster_instance.html ) in the cluster.
2016-06-09 23:45:29 +02:00
* `db_cluster_parameter_group_name` - (Optional) A cluster parameter group to associate with the cluster.
2016-07-21 00:52:34 +02:00
* `kms_key_id` - (Optional) The ARN for the KMS encryption key. When specifying `kms_key_id` , `storage_encrypted` needs to be set to true
2015-08-04 23:24:55 +02:00
## Attributes Reference
The following attributes are exported:
* `id` - The RDS Cluster Identifier
* `cluster_identifier` - The RDS Cluster Identifier
* `cluster_members` – List of RDS Instances that are a part of this cluster
* `allocated_storage` - The amount of allocated storage
* `availability_zones` - The availability zone of the instance
* `backup_retention_period` - The backup retention period
2015-11-04 20:40:22 +01:00
* `preferred_backup_window` - The backup window
* `preferred_maintenance_window` - The maintenance window
2016-07-21 20:55:10 +02:00
* `endpoint` - The DNS address of the RDS instance
2015-08-04 23:24:55 +02:00
* `engine` - The database engine
* `engine_version` - The database engine version
* `maintenance_window` - The instance maintenance window
* `database_name` - The database name
* `port` - The database port
* `status` - The RDS instance status
* `username` - The master username for the database
2016-03-08 22:51:16 +01:00
* `storage_encrypted` - Specifies whether the DB cluster is encrypted
2015-11-04 20:40:22 +01:00
* `preferred_backup_window` - The daily time range during which the backups happen
2015-08-04 23:24:55 +02:00
2016-01-14 21:55:39 +01:00
[1]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html
2015-08-04 23:24:55 +02:00
2016-01-14 21:55:39 +01:00
[2]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Aurora.html
2015-08-04 23:24:55 +02:00
[3]: /docs/providers/aws/r/rds_cluster_instance.html
2015-12-18 18:43:33 +01:00
[4]: http://docs.aws.amazon.com/fr_fr/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html
2016-07-21 00:28:59 +02:00
## Import
2016-07-21 20:55:10 +02:00
RDS Clusters can be imported using the `cluster_identifier` , e.g.
2016-07-21 00:28:59 +02:00
```
$ terraform import aws_rds_cluster.aurora_cluster aurora-prod-cluster
2016-07-21 20:55:10 +02:00
```