How to write an if, else, elsif conditional statement 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)}"
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)