gpt4 book ai didi

azure - 如何根据变量值运行 terraform 模块?

转载 作者:行者123 更新时间:2023-12-03 02:12:39 24 4
gpt4 key购买 nike

我只想在变量具有特定值时运行 terraform 模块例如,我只希望该模块在变量值为“y”时运行。这可能吗?

    module "azure-resource-group" {
source = "./modules/azure-resource-group"
name = "rgtest"
location = "west europe"
}

最佳答案

最简单的方法是使用count:

module "azure-resource-group" {

count = var.myvar == "y" ? 1 : 0

source = "./modules/azure-resource-group"
name = "rgtest"
location = "west europe"
}

但是,当您实际创建模块时,您必须使用index.html来引用它。例如:

locals {
id = module.azure-resource-group[0].id
}

关于azure - 如何根据变量值运行 terraform 模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72827076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com