simple conditional flag in terraform

Sometimes, you just need a very simple flag for enabled or disabled, or perhaps just a resource to deploy if var.stage == "qa". This works well for a single resource as well as collections if you provide the splat syntax.

1
2
3
4
5

resource "aws_ssm_association" "something_i_need_in_testing_only" {
   count = var.stage == "qa" ? 1 : 0
   name = var.name
}

Webmentions

(No webmentions yet.)