【发布时间】:2021-07-17 03:30:50
【问题描述】:
为以下要求寻找可能的解决方案/方法。
我有一个如下的变量
nodes= {
"type1" = {
max_size = 4
tags = { "key1" = "value1"
"key2" = "value2" } # structure of tags can be changed as needed
}
然后我有一个本地人将引用此标签以在 asg 中使用
locals {
for nodetype, nodeconfig in var.nodes
..
..
node_tags = nodeconfig.tags
}
local.node_tags 必须采用以下最终形式
{
"key" = "key1"
"value" = "value1"
"propagate_at_launch" = "true"
},
{
"key" = "key2"
...
...
}
我需要在 asg 中使用这些
resource "aws_autoscaling_group" "nodes" {
for_each = { for i in local.nodes ....
...
...
tags = each.value.node_tags
}
类似的用例 - https://github.com/terraform-aws-modules/terraform-aws-autoscaling#tags
我在下面尝试了一些东西..看起来很丑而且不起作用。
locals {
for nodetype, nodeconfig in var.nodes
..
..
node_tags = {for i in nodeconfig.tags : "{i}" => {
"key" = keys(i),
"value" = values(i),
"propagate_at_launch" = "true"
}
}
}
【问题讨论】:
标签: amazon-web-services terraform terraform-provider-aws terraform0.12+