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

packer subcommands (console,inspect,validate) should support HCL format #8538

nqb opened this issue Dec 23, 2019 · 12 comments · Fixed by #9468

packer subcommands (console,inspect,validate) should support HCL format #8538

nqb opened this issue Dec 23, 2019 · 12 comments · Fixed by #9468


Copy link

nqb commented Dec 23, 2019

Feature Description

Starting from Packer 1.5.0, we could use HCL templates in place of JSON templates but it looks like packer validate doesn't yet support HCL format.

Use Case(s)


source "docker" "example" {
       image = "centos:7"
       commit = "true"

build {
    sources = [

    provisioner "ansible" {
        playbook_file = "site.yml"
$ packer validate test.pkr.hcl 
Failed to parse template: Error parsing JSON: invalid character 's' looking for beginning of value
At line 1, column 1 (offset 1):
    1: s
Copy link
Contributor Author

nqb commented Dec 23, 2019

It seems to be the case for console and inspect too. I'm updating subject of issue.

From my point of view, having a support of validate is a must have when you want to migrate your template from JSON to HCL.

@nqb nqb changed the title packer validate should support HCL format packer subcommands (console,inspect,validate) should support HCL format Dec 23, 2019
Copy link

azr commented Jan 6, 2020

Hello @nqb, thanks for opening 🙂 !

#8423 only covered packer build, and we want to allow using HCL files for all of those commands, this is definitely something we want to do.

@azr azr added the hcl2 label Jan 6, 2020
Copy link

jcchak commented Mar 6, 2020


If possible please also make packer validate arguments consistent with packer build.

For instance now we can trigger a build with:

packer build <DIRECTORY>

But if we try to validate our code with packer validate <DIRECTORY> we get the error Failed to parse template: read <DIRECTORY>: is a directory

I'm using Packer 1.5.4.

Best regards and thanks! (HCL support rocks, finally we can leave JSON behind :))

Copy link

NickLarsenNZ commented Mar 17, 2020

Hi @azr, I've just been revisting packer since the HCL support was added. Very keen to be able to validate and inspect my configs.

Are there any indications as to time, or issues tracking these features? I couldn't find any myself.

Copy link

azr commented Mar 18, 2020

@NickLarsenNZ super nice :D. The short answer is we want to work on this but we don't know when this will be done.

We don't have a public schedule to share; but this is in our priority list and I think it's the next major thing I want to work on. Now please note that due to the current circumstances we could postpone working on hard features because it can be harder than usual to focus and everything. 🙂

Copy link

unacceptable commented Apr 2, 2020

I just ran into this in Packer 1.5.5. What would it take to get this assigned to a milestone?

@azr azr added this to the 1.5.6 milestone Apr 6, 2020
@azr azr modified the milestones: 1.5.6, 1.5.7 Apr 22, 2020
@nywilken nywilken modified the milestones: 1.5.7, 1.6.0 Apr 29, 2020
Copy link

julian-alarcon commented May 4, 2020

As a workaround for validate, I rename the packer files to .tf extension and then use the formatter from Terraform, terraform fmt.
Not elegant but works.

Copy link

bminahan-kc commented May 19, 2020

+1 for validate specifically

Copy link

daneharrigan commented Jun 1, 2020

@julian-alarcon that was a good suggestion. I did the same, but used STDIN so I wouldn't need to rename files: cat file.pkr.hcl | terraform fmt - or add -check and look at the exit-code.

Copy link

azr commented Jun 12, 2020

Ah, we still miss the inspect command, should I make another issue and rename this one ?

@azr azr reopened this Jun 12, 2020
Copy link

nitrocode commented Jun 12, 2020

Let's use this one since it already has the context

Copy link

ghost commented Jul 24, 2020

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.

@hashicorp hashicorp locked and limited conversation to collaborators Jul 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.