Packer legacy JSON template deprecation in CI
Packer deprecated the legacy JSON template format in favor of HCL2. Newer Packer prints a deprecation notice for .json templates and can fail if the JSON uses features no longer supported.
What this error means
packer build on a .json template prints a deprecation warning, or fails on a legacy field, recommending you migrate to HCL2 with packer hcl2_upgrade.
packer
Warning: Deprecated: the JSON template format is deprecated.
Use HCL2 instead. To upgrade this template run: packer hcl2_upgrade template.jsonCommon causes
The pipeline still builds a JSON template
The .json format is deprecated, so newer Packer warns on every run and may reject removed fields.
A JSON-only feature has no HCL equivalent path
Some legacy constructs are unsupported in current Packer, causing a hard failure rather than a warning.
How to fix it
Upgrade the template to HCL2
- Run
packer hcl2_upgradeon the JSON template. - Review the generated
.pkr.hcland adjust variables and sources. - Point the CI build at the HCL2 template.
Terminal
packer hcl2_upgrade template.json
packer validate template.pkr.hclPin an older Packer only as a stopgap
If you cannot migrate immediately, pin a Packer version that still accepts the JSON template, but plan the HCL2 move.
How to prevent it
- Migrate JSON templates to HCL2 with
packer hcl2_upgrade. - Run
packer validateon the HCL2 output in CI. - Track Packer release notes for removed legacy features.
Related guides
Packer "Failed to parse" a .pkr.hcl file in CIFix Packer HCL parse errors in CI - a .pkr.hcl file has a syntax error such as an unclosed block or missing q…
Packer "Unsupported argument" in a .pkr.hcl block in CIFix Packer "Error: Unsupported argument" in CI - a source, build, or provisioner block sets an argument that…
Packer "references unknown source" in a build block in CIFix Packer "build references unknown source" in CI - a build block lists a sources entry that does not match…