jeyyu2003
jeyyu2003

Reputation: 57

multiple outputs in a single string in Terraform

Terraform provides excellent documentation for displaying outputs including AWS.

output "ip" {
  value = "${aws_eip.ip.public_ip}"
}

That would in term provide something like

ip = 50.17.232.209

what I would like to get if possible is something like:

public_ip = x.x.x.x and private_ip = y.y.y.y

in one line as opposed to separate items. I have tried something like this:

output "public ip and private ip" {
  value = "${aws_eip.ip.public_ip}"
  value = "${aws_eip.ip.private_ip}"
}

Currently, It's working if I split them up like this:

output "public_ip" {
  value = "${aws_eip.ip.public_ip}"
}

output "private_ip" {
  value = "${aws_eip.ip.private_ip}"
}    

Thanks

Upvotes: 1

Views: 5230

Answers (1)

StephenKing
StephenKing

Reputation: 37630

The following should work, although splitting them up probably makes most sense:

output "public ip and private ip" {
  value = "public_ip = ${aws_eip.ip.public_ip} and private_ip = ${aws_eip.ip.private_ip}"
}

Maybe you have to tune it a bit to have the formatting as you prefer, but I hope that my answer at least shows that there is nothing special compared to string interpolation somewhere else..

Upvotes: 2

Related Questions