Reputation: 3965
I would like to display the public_ip of aws_instance created by terraform after terraform execution.
However, only the global IP of the first server appears.
My source code is as follows.
resource "aws_instance" "main" {
count = "3"
...
}
output "ec2_global_ips" {
value = "${aws_instance.main.*.public_ip}"
}
Is something wrong grammar? Let me know if you have to know how to display array values as output in terraform.
Upvotes: 7
Views: 10841
Reputation: 23
I hope this helps.
output "ec2_global_ips" {
value = [for instance in aws_instance.main : instance.public_ip]
}
Upvotes: 1
Reputation: 735
I believe this will work:
output "ec2_global_ips" {
value = ["${aws_instance.main.*.public_ip}"]
}
Upvotes: 13