packer/command/test-fixtures/hcl2_upgrade/undeclared-variables/input.json
Wilken Rivera dbeeab448a
cmd/hcl2_upgrade: Generate variable block for all referenced user input variables (#12136)
Currently the HCL2 upgrade command generates a valid variable block for all variables
within the JSON variables property. However JSON templates in Packer support variable
interpolation for input variables defined within a variable definition file without
it being declared within the variables property. When upgrading a JSON template to HCL2
the user variable reference gets converted to var.<var_name>. The upgraded template ultimately
fails on validation or build execution with undefined variable errors, with this change the upgrade
command will now create a variable block for all input variables referenced within the build template
to ensure all required variables been defined.
2022-11-30 15:25:25 -05:00

18 lines
302 B
JSON

{
"variables": {
"foo": "bar"
},
"builders": [
{
"type": "null",
"communicator": "{{ user `communicator_type` }}"
}
],
"provisioners": [
{
"type": "shell",
"script": "{{user `scriptpath`}}"
}
]
}