Hi,
I'm trying to set up a new Aurora DB cluster on AWS, and want it in 2 availability zones.
Creating it is no problem and everything is correct, but if I try to run terraform apply again it tells me that the DB cluster has changed and deletes it and re-creates.
If I run plan for it, this is what is logged out:
-/+ aws_rds_cluster.rds
apply_immediately: "" => "<computed>"
availability_zones.#: "3" => "2" (forces new resource)
availability_zones.2050015877: "us-west-2c" => ""
availability_zones.221770259: "us-west-2b" => "us-west-2b" (forces new resource)
availability_zones.2487133097: "us-west-2a" => "us-west-2a" (forces new resource)
Nothing has changed in the configuration between the two times I run terraform.
Is there anything I can do so it will not constantly delete and re-create the database every time I make some changes to the configuration?
My configuration is like this:
variable "availabiliy_zones" {
default = "us-west-2a,us-west-2b"
}
### RDS ###
resource "aws_db_subnet_group" "db-subnet-group" {
name = "${var.environment_name}-db-subnet-group"
description = "${var.environment_name} DB Subnet group"
subnet_ids = ["${aws_subnet.data-subnet.*.id}"]
tags {
Name = "${var.environment_name}-db-subnet-group"
Environment = "${var.environment_name}"
}
}
resource "aws_rds_cluster" "rds" {
cluster_identifier = "${var.environment_name}-aurora-cluster"
master_username = "user"
master_password = "userpass"
availability_zones = ["${split(",", var.availabiliy_zones)}"]
backup_retention_period = 14
preferred_backup_window = "04:00-05:00"
vpc_security_group_ids = ["${element(aws_security_group.public.*.id, count.index)}"]
db_subnet_group_name = "${aws_db_subnet_group.db-subnet-group.id}"
}
resource "aws_rds_cluster_instance" "rds-instance" {
identifier = "${var.environment_name}-aurora-instance-${count.index}"
cluster_identifier = "${aws_rds_cluster.rds.cluster_identifier}"
instance_class = "db.r3.large"
publicly_accessible = true
db_subnet_group_name = "${aws_db_subnet_group.db-subnet-group.id}"
count = "${length(split(",", var.availabiliy_zones))}"
tags {
Name = "${var.environment_name}-rds-instance-${count.index}"
Environment = "${var.environment_name}"
}
}
Regards,
Albert