Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Heredoc breaks formatting (<<EOF...EOF) #164

Closed
5 tasks done
j0hnsmith opened this issue Sep 17, 2018 · 3 comments
Closed
5 tasks done

Heredoc breaks formatting (<<EOF...EOF) #164

j0hnsmith opened this issue Sep 17, 2018 · 3 comments

Comments

@j0hnsmith
Copy link

j0hnsmith commented Sep 17, 2018

Prerequisites

  • Ensure you have latest version of plugin installed
  • Search for possible issue duplicates

Installation details

  • IDE version (Help->About->Copy to Clipboard)
    GoLand 2018.2.2
    Build #GO-182.4129.57, built on August 23, 2018
    Licensed to someone
    Subscription is active until May 21, 2019
    JRE: 1.8.0_152-release-1248-b8 x86_64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    macOS 10.12.6

  • intellij-hcl plugin version (Settings->Plugins)
    0.6.12

  • Terraform version (terraform -v)
    v0.11.7

Terraform Configuration Files

resource "aws_s3_bucket" "somesite" {
  region = "${local.region}"
  bucket = "somesite-com"
  acl    = "public-read"
  website {
    index_document = "index.html"
    //    error_document = "error.html"
  }
  policy = <<POLICY
{
  "Version":"2012-10-17",
  "Statement":[{
	"Sid":"PublicReadGetObject",
      "Effect":"Allow",
	  "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::somesite-com/*"]
    }
  ]
}POLICY

}

output "somesite_website_endpoint" {
  value = "${aws_s3_bucket.somesite.website_endpoint}"
}

Expected Behavior

What should have happened?

The output block at the bottom of the config should be formatted correctly. If I move it about the resource block (eg before the heredoc block) it is formatted correctly.

Actual Behavior

What actually happened?

screenshot

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

Create config with a <<EOF...EOF block that also has additional config after it, the config after won't be formatted correctly.

Interesting that the github code formatting has the same formatting problem.

@VladRassokhin
Copy link
Owner

VladRassokhin commented Sep 17, 2018

I think the problem here is that second POLICY should start on newline, not after some characters. Even highlighting shows that.
Proper heredoc use:

a = <<POLICY
{
}
POLICY

@j0hnsmith
Copy link
Author

Ahh, thanks, that works.

However it seems to be valid syntax without the new line, as far as terraform is concerned (it runs it without complaining), and terraform fmt doesn't correct it. Happy to close though.

@VladRassokhin
Copy link
Owner

That was actually a bug in hcl parser itself, resolved in hashicorp/hcl#245
AFAIU future versions of Terraform would not support that syntax as it contradicts usual 'heredoc' definition used in bash, etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants