Terraform: v0.14.0-rc1 regression: Incorrectly rendered newlines in terraform output

Created on 26 Nov 2020  ยท  3Comments  ยท  Source: hashicorp/terraform

Identified regression in 0.14.0-rc: multi-line output is incorrectly rendered (rendered without newline characters).

Terraform Version

Terraform v0.14.0-rc1

  • provider registry.terraform.io/hashicorp/archive v2.0.0
  • provider registry.terraform.io/hashicorp/aws v3.17.0
  • provider registry.terraform.io/hashicorp/http v2.0.0
  • provider registry.terraform.io/hashicorp/local v2.0.0
  • provider registry.terraform.io/hashicorp/null v3.0.0
  • provider registry.terraform.io/hashicorp/random v3.0.0

Terraform Configuration Files

output "my_out" {
  value = <<EOF
This is a
multiline
string.
EOF
}

Expected Behavior

Expected behavior is that the output is rendered with newline characters. This is especially important for longer strings and strings which pass URLs as part of a pre-formatted output string.

This is the output from 0.12.x and 0.13.x:

my_out = This is a
multiline
string.

Actual Behavior

Output does not render newlines but mashes multiple lines together. This breaks links and makes longer output strings unreadable to the user.

my_out = This is a\nmultiline\nstring.

Steps to Reproduce

  1. Create output variable with multiple lines.
  2. Run terraform apply or terraform output

Additional Context

This is especially important for modules which pass usability info (esp. links and other info) on to consumer of the module.

bug confirmed explained

Most helpful comment

There's a fix pending review in #27045. With that branch, the original reproduction case here renders as follows:

$ terraform apply -auto-approve

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

my_out = <<EOT
This is a
multiline
string.

EOT

All 3 comments

Thanks for reporting this, @aaronsteers. I've confirmed the issue in Terraform 0.14.0-rc1.

This change is a consequence of the change in console and output rendering, which aimed to ensure that these values were presented as valid HCL values. The fix will require rendering strings containing newlines in the heredoc format.

There's a fix pending review in #27045. With that branch, the original reproduction case here renders as follows:

$ terraform apply -auto-approve

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

my_out = <<EOT
This is a
multiline
string.

EOT

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

Related issues

rkulagowski picture rkulagowski  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

thebenwaters picture thebenwaters  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments