diff --git a/hcl2template/parser.go b/hcl2template/parser.go index df6ef1d86..3bf48294e 100644 --- a/hcl2template/parser.go +++ b/hcl2template/parser.go @@ -126,6 +126,11 @@ func (p *Parser) parse(filename string, vars map[string]string) (*PackerConfig, diags = append(diags, cfg.collectInputVariableValues(os.Environ(), varFiles, vars)...) } + _, moreDiags := cfg.InputVariables.Values() + diags = append(diags, moreDiags...) + _, moreDiags = cfg.LocalVariables.Values() + diags = append(diags, moreDiags...) + // decode the actual content for _, file := range files { diags = append(diags, p.decodeConfig(file, cfg)...) diff --git a/hcl2template/testdata/variables/basic.pkr.hcl b/hcl2template/testdata/variables/basic.pkr.hcl index c495ed741..8fb119b0c 100644 --- a/hcl2template/testdata/variables/basic.pkr.hcl +++ b/hcl2template/testdata/variables/basic.pkr.hcl @@ -29,6 +29,7 @@ variable "super_secret_password" { description = <