In terraform modules variable ensure that one of the two variable is always present

43 views Asked by At

In terraform modules variables, how to ensure that one of the two variables is always present and not both?

modules/app_function

variable app1_version {
  description = "APP1 Version"
  type = string
}
variable app2_version {
  description = "APP2 Version"
  type = string
}

##Usage
app/myapplications

module "myapp1" {
  source        = "../modules/app_function/"
  app2_version = "v4.4"
  other_variable = abc
}
module "myapp2" {
  source        = "../modules/app_function/"
  other_variable = abc
}

myapp1 should be valid and myapp2 should not be valid.

0

There are 0 answers