diff --git a/modules/packer/packer.go b/modules/packer/packer.go index dd1f418ce..58439b796 100644 --- a/modules/packer/packer.go +++ b/modules/packer/packer.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "regexp" "sync" "time" @@ -214,6 +215,12 @@ func packerInit(t testing.TestingT, options *Options) error { return nil } + extension := filepath.Ext(options.Template) + if extension != ".hcl" { + options.Logger.Logf(t, "Skipping 'packer init' because it is only supported for HCL2 templates") + return nil + } + cmd := shell.Command{ Command: "packer", Args: []string{"init", options.Template},