Aid*_*len 7 foreach module dynamic terraform0.12+
如何动态地将地图解包到模块/资源属性中?我知道您可以在 terraform 12/13 中执行动态资源属性块,但是您可以对整个资源/模块的所有属性执行此操作吗?例如:
module "this" {
for_each = {
att0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
each.key = each.value
}
# my hope is that this would do the equivalent of this code below
module "this" {
attr0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
Run Code Online (Sandbox Code Playgroud)
与在 python 中使用 splat kwargs 到函数中的方式类似。例如
module "this" {
for_each = {
att0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
each.key = each.value
}
# my hope is that this would do the equivalent of this code below
module "this" {
attr0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
Run Code Online (Sandbox Code Playgroud)
我尝试过的其他变体:
module "this" {
for_each = {
att0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
}
Run Code Online (Sandbox Code Playgroud)
module "this" {
{
att0 = "attr0"
attr1 = "attr1"
attr2 = "attr2"
}
}
Run Code Online (Sandbox Code Playgroud)