【发布时间】:2018-11-28 16:55:18
【问题描述】:
我正在尝试获取与 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}"
【问题讨论】:
-
只是一个旁注:指定实例 ID 和其他过滤器是多余的,因为实例 ID 是唯一的。
标签: terraform aws-security-group