【问题标题】:Conditionally enable or disable modules in root main.tf terraform有条件地启用或禁用根 main.tf terraform 中的模块
【发布时间】:2021-10-06 02:36:15
【问题描述】:

我们如何在根 main.tf 中选择或禁用模块

例子:

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

}

以上一个不起作用,根据 terraform 问题讨论link

任何替代方法?

【问题讨论】:

    标签: amazon-web-services azure google-cloud-platform terraform hcl


    【解决方案1】:

    您使用的是什么版本的 Terraform?在 Terraform 版本 0.13.0 中引入了模块的 countfor_each

    请注意,您使用的插值语法已弃用。使用:

    count = var.include_module ? 1 : 0
    

    【讨论】:

    • 我使用的是 0.12,更改了 terraform 二进制文件并正常工作
    猜你喜欢
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-14
    • 2021-11-20
    • 2021-06-05
    • 1970-01-01
    • 2022-07-01
    相关资源
    最近更新 更多