MBHA Phoenix
MBHA Phoenix

Reputation: 2217

Terraform: how to set the value of a string on multiple lines but the result is one line

For readability purpose, I want to set the value of a string on multiple lines but the result would show as a one ligne. I tried to contact using + but it does not work. By the way, one of the lines (a part of the string) is resolved at apply time.

example:

output "variable" {
    value = "First part "
          + ", then second part "
          + " and final part."
}

and the output.variable will show "First part, then second part and final part."

Upvotes: 1

Views: 2146

Answers (2)

Mark B
Mark B

Reputation: 200960

you can use the join function:

output "variable" {
    value = join("", ["First part ",
          ", then second part ",
          " and final part."])
}

Upvotes: 4

Antonio Gamiz Delgado
Antonio Gamiz Delgado

Reputation: 2113

Why don’t you try to concatenate adding a \n character at the end of every variable forming the string? Something like:

output “variable” {
    value = “${var}\n${var2}\n”
}

Upvotes: 0

Related Questions