I'm setting up a terraform module to create an aurora cluster.
I need to have an option for cross region replication so i need to decide the region of the replica in relation to the source region.
Is there any way to do a multiple option conditional in terraform?
This is one way using the coalesce() function:
locals{
prod = "${var.environment == "PROD" ? "east" : ""}"
prod2 = "${var.environment == "PROD2" ? "west2" : ""}"
nonprod = "${var.environment != "PROD" && var.environment != "PROD2" ? "west" : ""}"
region = "${coalesce(local.prod,local.prod2, local.nonprod)}"
}