Terraform“标签”; (复数)已弃用 - 如何创建多个“标签”条目?
因此,对于 Terraform 中的 ASG(自动缩放组)代码,最新的 AWS 提供商不推荐使用“标签”(复数),并要求使用单个“标签”条目。 因此,如果您需要多个标签,则需要多个单独的“标签”条目。 使用我当前的代码,我得到如下错误:
│ Warning: Argument is deprecated
│
│ with module.service.module.compute.module.controller.aws_autoscaling_group.controller,
│ on .terraform/modules/service/compute/controller/ec2.tf line 74, in resource "aws_autoscaling_group" "controller":
│ 74: tags = [for key, value in merge(local.asg_tags, var.compute_tags) :
│ 75: { key = key, value = value, propagate_at_launch = true }
│ 76: ]
│
│ Use tag instead
对于某些资源,我可以创建几个静态“标签”选项,例如
tag {
key = 1
}
tag {
name = 2
}
但是如果我当前的代码使用“for”循环来创建某种形式的平面地图或其他东西,创建标签???
│ 74: tags = [for key, value in merge(local.asg_tags, var.compute_tags) :
│ 75: { key = key, value = value, propagate_at_launch = true }
│ 76: ]
我相信它是相当新的功能,因为找不到任何有用的东西来对其进行排序的最佳实践是什么。 有人遇到过吗? 谢谢
So - for ASG's (auto scaling groups) code in Terraform, newest AWS provider deprecates usage of 'tags' (plural) and asks to use a single 'tag' entry.
So if you need mulitple tags, you need multiple individual 'tag' entries .
With my current code, i get the error that looks like :
│ Warning: Argument is deprecated
│
│ with module.service.module.compute.module.controller.aws_autoscaling_group.controller,
│ on .terraform/modules/service/compute/controller/ec2.tf line 74, in resource "aws_autoscaling_group" "controller":
│ 74: tags = [for key, value in merge(local.asg_tags, var.compute_tags) :
│ 75: { key = key, value = value, propagate_at_launch = true }
│ 76: ]
│
│ Use tag instead
For some resources i can create several static 'tag' options like
tag {
key = 1
}
tag {
name = 2
}
But how can i create some form of flat map or something, if my current code is using 'for' loops to create tags ???
│ 74: tags = [for key, value in merge(local.asg_tags, var.compute_tags) :
│ 75: { key = key, value = value, propagate_at_launch = true }
│ 76: ]
I believe its pretty new feature as can't find anything useful what is the best practise to get it sorted.
Has anyone came across that ?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有使用过它,但也许你可以使用 动态块。
根据我在 文档 中看到的内容,我认为它看起来像:
I haven't used it, but maybe you can can make use of a dynamic block.
Based on what I see in the docs I think it would look something like:
感谢@Chai 的提示,成功为标签创建动态块:
按预期工作!
Thank you @Chai for the hint, managed to create dynamic block for tags :
Works as expected !