Terraform: How to join instance tag and instance IP in one line

Created on 13 Feb 2018  ยท  2Comments  ยท  Source: hashicorp/terraform

Hi all,

I'm usingTerraform v0.11.3 and want to get output for multiple instances in

name1:ip address
name2:ip address

name3:ip adress

i want to join these outputs
`output "ip" {
value = "${aws_instance.example.*.public_ip}"
}

output "tag" {
value = "${aws_instance.example.*.tags.Name}"
}
`

i created below but getting
name1,
-,
ip address

output "ime" { value = ["${aws_instance.example.*.tags.Name}","${aws_instance.example.*.public_ip}"] }

question

Most helpful comment

Take a look at "formatlist".

Here's an untested example (based on something similar I've had to do):

output "ime" {
  value = "${
      formatlist(
        "%s:%s",
        aws_instance.example.*.tags.Name,
        aws_instance.example.*.public_ip4
      )
    }"
}

All 2 comments

Take a look at "formatlist".

Here's an untested example (based on something similar I've had to do):

output "ime" {
  value = "${
      formatlist(
        "%s:%s",
        aws_instance.example.*.tags.Name,
        aws_instance.example.*.public_ip4
      )
    }"
}

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings