Skip to content
Latchkey

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.json

Common 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

  1. Run packer hcl2_upgrade on the JSON template.
  2. Review the generated .pkr.hcl and adjust variables and sources.
  3. Point the CI build at the HCL2 template.
Terminal
packer hcl2_upgrade template.json
packer validate template.pkr.hcl

Pin 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 validate on the HCL2 output in CI.
  • Track Packer release notes for removed legacy features.

Frequently asked questions

What causes "JSON template deprecated"?
The .json format is deprecated, so newer Packer warns on every run and may reject removed fields.
How do I fix JSON template deprecated?
Upgrade the template to HCL2

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card