lundi 5 avril 2021

If statement in terraform, using 2 different code blocks

I have this codeblock

  launchpad_tmpl = {
    apiVersion = "<Link for the API>"
    kind       = "mke"
    spec = {
      mke = {
        adminUsername = "admin"
        adminPassword = var.admin_password
        installFlags : [
          "--default-node-orchestrator=kubernetes",
          "--san=${module.masters.lb_dns_name}",
        ]
      }
      hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
    }
  }
}

And I have another codeblock

  launchpad_tmpl = {
    apiVersion = "<Some link for the API>"
    kind       = "mke"
    spec = {
      mke = {
        adminUsername = "admin"
        adminPassword = var.admin_password
        installFlags : [
          "--default-node-orchestrator=kubernetes",
          "--san=${module.masters.lb_dns_name}",
        ]
      }

      msr = {
      ...some_code
      }
      hosts = concat(local.managers, local.msrs, local.workers, local.windows_workers)
    }
  }
}

I want to tell terraform something like

IF msr_count >= 1 - Use second codeblock to run ELSE use the first one...

Is it possible in Terraform Or I will need to make a wrapper somewhere? Thanks in Advance.

Aucun commentaire:

Enregistrer un commentaire