v0.8.8
-aws_rds_cluster_instance
resource "aws_db_subnet_group" "aurora-dev" {
name = "aurora-dev"
subnet_ids = ["${aws_subnet.main.id}", "${aws_subnet.main_2.id}"]
}
resource "aws_rds_cluster" "aurora-dev" {
cluster_identifier = "aurora-dev"
availability_zones = ["us-east-1a", "us-east-1b"]
db_subnet_group_name = "${aws_db_subnet_group.aurora-dev.id}"
database_name = "${var.aurora_database}"
master_username = "${var.aurora_username}"
master_password = "${var.aurora_password}"
backup_retention_period = 1
preferred_backup_window = "05:00-06:00"
port = 3306
}
resource "aws_rds_cluster_instance" "aurora" {
count = 2
identifier = "aurora-dev"
cluster_identifier = "${aws_rds_cluster.aurora-dev.id}"
db_subnet_group_name = "${aws_db_subnet_group.aurora-dev.id}"
publicly_accessible = false
instance_class = "db.r3.large"
}
Both Instances in aws_rds_cluster_instance should provision without a problem.
Error applying plan:
1 error(s) occurred:
Please list the steps required to reproduce the issue, for example:
terraform applyFrom the docs:
identifier - (Optional) The Instance Identifier. Must be a lower case string. If omitted, a unique identifier will be generated.
You should either remove the identifier and let it be auto generated or add some randomness to the name, for example aurora-dev-${uuid()}
@pradyuman you might need to a destroy and apply again. And the destroy here doesn't deletes my _aws_rds_cluster_ resource. See this GH-12584
Ok changing the identifier allowed me to create my aurora instances, but now everytime I apply terraform it reprovisions the cluster because it the availability zones are out of sync:

My config is like this now:
resource "aws_rds_cluster" "aurora" {
cluster_identifier = "aurora-dev"
availability_zones = ["${var.availability_zone}"]
db_subnet_group_name = "${aws_db_subnet_group.aurora.id}"
vpc_security_group_ids = ["${aws_security_group.aurora.id}"]
database_name = "${var.aurora_database}"
master_username = "${var.aurora_username}"
master_password = "${var.aurora_password}"
backup_retention_period = 1
preferred_backup_window = "05:00-06:00"
port = 3306
}
For some reason terraform thinks my remote rds cluster has three availability zones when it only has one.
Ok I found this issue: https://github.com/hashicorp/terraform/issues/3754. However, there doesn't seem to be an option to restrict rds instances to one availability zone. Am I missing something here?
@pradyuman
Don't specify availability zones at all.
Create a db subnet group that contains ONLY the subnet you want to deploy to. (Note that this means you will lose HA across zones since if your instances go down in the zone the subnet belongs to, it wont auto relaunch in another subnet in another zone)
Using ${count.index} worked well for us
From https://www.terraform.io/docs/providers/aws/r/rds_cluster_instance.html
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.r3.large"
}
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.