Terraform:有条件地安装 TF 模块

Terraform: Conditionally install TF module

我创建了一个 Terraform 模块(安装 jenkins,但这超出了这个问题的范围)

我希望能够有条件地安装它。

我试过 count 方法:

module "jenkins" {
  count = "${var.install_jenkins}"
  source        = "../../../../modules-terraform/jenkins"
  project_id         = "${google_project.service.project_id}"
  zone = "${var.zone}"
  org_name = "${var.org_name}"
}

但它抛出以下错误:

Error: module "jenkins": "count" is not a valid argument

有没有办法有条件地安装 Terraform 模块?

使用 Terraform 0.11.14

如果升级到 Terraform 0.13.x,您可以使用 count 有条件地应用模块。参见 https://github.com/hashicorp/terraform/blob/guide-v0.13-beta/README.md and https://github.com/hashicorp/terraform/tree/guide-v0.13-beta/module-repetition