Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yamlencode function includes heredoc anchors in output #27251

Closed
rojopolis opened this issue Dec 11, 2020 · 3 comments
Closed

Yamlencode function includes heredoc anchors in output #27251

rojopolis opened this issue Dec 11, 2020 · 3 comments
Assignees
Labels
bug working as designed confirmed as reported and closed because the behavior is intended

Comments

@rojopolis
Copy link

Terraform Version

0.14.0 - 0.14.2

Terraform Configuration Files

output "yaml" {
  value = yamlencode({ foo = "bar" })
}

Debug Output

Crash Output

Expected Behavior

Output valid yaml as previous Terraform versions do.

Actual Behavior

tf output yaml
<<EOT
"foo": "bar"

EOT

Steps to Reproduce

terraform init
terraform apply
terraform output yaml

Additional Context

References

@rojopolis rojopolis added bug new new issue not yet triaged labels Dec 11, 2020
@danieldreier danieldreier added confirmed a Terraform Core team member has reproduced this issue v0.14 and removed new new issue not yet triaged labels Dec 11, 2020
@danieldreier
Copy link
Contributor

Thank you for reporting this! I've reproduced this exactly as reported in 0.14.2.

@alisdair alisdair self-assigned this Dec 11, 2020
@alisdair
Copy link
Contributor

Hi @rojopolis, thanks for reporting this.

The yamlencode function returns a string, which is then displayed by terraform output as a heredoc because it has multiple lines. We changed the format of terraform output in 0.14 to make it clearer what type values were, and to allow the output value to be used directly in HCL.

It sounds like you're trying to use this output in an automated setting, where the heredoc markers make this difficult. We do not support using the terraform output text UI in automation, and instead suggest using the stable JSON output. For example:

$ terraform output -json yaml | jq -r
"foo": "bar"

In an upcoming 0.14 patch release we are also adding a -raw flag to terraform output, which would also be an option here:

$ terraform output -raw yaml
"foo": "bar"

See #27212 for more details on -raw.

I'm marking this closed as Terraform is working as designed, and there are two workarounds described above. Thanks again for reporting!

@alisdair alisdair added working as designed confirmed as reported and closed because the behavior is intended and removed confirmed a Terraform Core team member has reproduced this issue labels Dec 11, 2020
@ghost
Copy link

ghost commented Jan 11, 2021

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.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug working as designed confirmed as reported and closed because the behavior is intended
Projects
None yet
Development

No branches or pull requests

3 participants