Terraform-合并顶级资源参数



是否可以以某种方式定义映射变量或类似的东西,然后将其扩展为顶级资源参数?类似于如何在yaml中执行<<:

我已经研究过合并地图和覆盖文件,但看起来它们不适合这样做。

例如,我有这样的

resource "resource_type" "res1" {
a = 1
b = 2
c = 3
special = "res1"
}
resource "resource_type" "res2" {
a = 1
b = 2
c = 3
special = "res2"
}

我想要实现的目标:

locals {
common_args = {
a = 1
b = 2
c = 3
}
}

resource "resource_type" "res1" {
<put content of locals.common_args here>
special = "res1"
}
resource "resource_type" "res2" {
<put content of locals.common_args here>
special = "res2"
}

如果可以使用count=for_each合并资源块,那可能是最好的。您仍然可以计算单独的";特别的";等等。

但是,如果它们必须是分开的,那么每个块中的资源属性模式应该可以工作:a = local.common_args["a"]

最新更新