lundi 6 décembre 2021

Terraform Conditionals

I have 4 envs, qa and dev use one ID, uat and prod use another. I'm trying to do an if else, basically, if env is dev or qa, use id1, else use id2. This is what I tried:

locals{
  endpoint_id = "${var.env == "dev" || "qa" ? "id1" : "id2"}"
}

And this is what I get:

Error: Invalid operand
│ 
│   on ssm-parameters.tf line 2, in locals:
│    2:   endpoint_id = "${var.env == "dev" || "qa" ? "id1" : "id2"}"
│ 
│ Unsuitable value for right operand: a bool is required.

Apparently I can't do an "OR" here. How would I go about this? Thank you.

Aucun commentaire:

Enregistrer un commentaire