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

HashiCorp Configuration Language (HCL) Support #1353

Open
karras opened this issue Jan 9, 2020 · 16 comments · Fixed by #1756
Open

HashiCorp Configuration Language (HCL) Support #1353

karras opened this issue Jan 9, 2020 · 16 comments · Fixed by #1756

Comments

@karras
Copy link

karras commented Jan 9, 2020

The HashiCorp Configuration Language (HCL) is becoming very popular these days and also very handy to have in other projects such as MediaWiki, which make use of pygments.

@karras
Copy link
Author

karras commented Jan 9, 2020

Specification: https://github.com/hashicorp/hcl

@hairmare ^

@appleshampooid
Copy link

pygments does support HCL but you have to label it as terraform which isn't 100% accurate, but seems to work pretty well for me.

@karras
Copy link
Author

karras commented Jun 14, 2020

Good catch, totally missed that one. Thanks!

@lgiordani
Copy link
Contributor

Can you please have a look at #1756? Feedback is welcome. Thanks!

@lorengordon
Copy link

@lgiordani I have a block that looks like this, which is failing when using pygments 2.9.0 with WARNING: Could not lex literal_block as "terraform". Highlighting skipped. Strange thing is this syntax is valid with both HCL 1 and HCL 2, and it was working fine with pygments 2.8.1.

```terraform
provider "aws" {}

module "test-lx-instance" {
  source = "git::https://github.com/plus3it/terraform-aws-watchmaker//modules/lx-instance/"

  Name      = "tf-watchmaker-lx-autoscale"
  AmiId     = "__AMIID__"
  AmiDistro = "__AMIDISTRO__"
}

@lgiordani
Copy link
Contributor

@lorengordon I'll have a look as soon as possible, thanks for the test case

@Anteru Anteru linked a pull request Jun 20, 2021 that will close this issue
@Anteru
Copy link
Collaborator

Anteru commented Jun 20, 2021

Can someone confirm this fixed by #1756? I see an error on the first } but that seems unrelated?

@Jeinhaus
Copy link

Jeinhaus commented Jul 5, 2021

I am using terragrunt that also uses HCL for configuration. The changes from #1756 do not fix that. Should I open another issue for this (even though it's using HCL)?

An example for terragrunt's configuration is below:

terraform {
  source =
    "github.com:foo/infrastructure-modules.git//app?ref=v0.0.1"
}
inputs = {
  instance_count = 10
  instance_type  = "m4.large"
}

@Anteru
Copy link
Collaborator

Anteru commented Jul 18, 2021

Given #1756 doesn't fix your issue, but is already merged, I'd suggest to open a new one. For my understanding: Is terragrunt using a dialect of HCL or is that a problem for "plain" HCL?

@lorengordon
Copy link

@Anteru The linked PR #1756 is included in the 2.9.0 release and does not appear to fix this issue. I can't test what it does work for, but it does not work for basic Terraform syntax that is the same in both HCL2 and HCL1, as I mentioned above.

@lgiordani
Copy link
Contributor

Hi all, my work on #1756 was checked against a large Terraform code base (~100k lines), but I didn't implement the HCL specification following it rule by rule, so I'm not surprised that isn't covered. I think it's simpler to open a new issue with the failing use case and steps to reproduce so that whoever has time to look into it can easily create the test environment.

@lorengordon
Copy link

@lgiordani Just closing the loop, there's a patch for the problem I was noticing in #1987 ...

@lgiordani
Copy link
Contributor

Thank you @lorengordon!

@lorengordon
Copy link

There's a chance support for the syntax regression I mentioned was fixed in #2097. Just waiting on the next release to test it.

@lorengordon
Copy link

Can confirm #2097 fixed the issue for us, in the 2.12.0 release.

@lgiordani
Copy link
Contributor

Thank you @lorengordon!

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

Successfully merging a pull request may close this issue.

6 participants