Conditionally enable or disable modules in root main.tf terraform

Viewed 5921

How do we select or disable modules in root main.tf

Example:

module "foo" {
  source = "bar"
  count   = "${var.include_module ? 1 : 0}"

}

Above one does not work, as per terraform issue discussion link

Any alternate method ?

1 Answers

What version of Terraform are you using? count and for_each for modules were introduced in Terraform version 0.13.0.

Note that the interpolation syntax you're using is deprecated. Use:

count = var.include_module ? 1 : 0
Related