terraform - 如何使用 terraform 过滤 ec2 实例的关联安全组
问题描述
我正在尝试获取与 ID 为“i-0abcdefgh1234”的实例关联的安全组,但输出没有结果。
terraform.tf
data "aws_instance" "ec2" {
instance_id = "i-0abcdefgh1234"
filter {
name = "tag:Name"
values = ["name-of-the-server"]
}
}
output "sg" {
value = "${data.aws_instance.ec2.*.security_groups}"
}
输出
data.aws_instance.ec2: Refreshing state...
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
尝试使用和不使用以下 *
value = "${data.aws_instance.ec2.*.security_groups}"
解决方案
推荐阅读
- javascript - 在 tr 中找到 td 的方法。(Javascript)
- excel - Worksheet_SelectionChange() 可以在选择图片或图像时触发吗?在 Excel VBA 中
- python - 规范化外来文本
- model-view-controller - 仅在新选项卡中未从 partial_view 调用控制器 ActionResult
- javascript - Vue动态背景图片内联组件
- django - Django admin annotation - Sum 相关模型的字段
- python - 如何找到一个单词在给定字符串中连续重复的最大次数?
- powershell - 为 txt 文件中的每个对象下载
- python - 如何修复代码以抓取 Zomato 网站?
- javascript - 暂时停止 keydown 事件触发