sincecutoff.com
← all changes

Packer HCL2 object variables support optional attributes

Introduced 2026-07-24 · score 0.99

HOW TO USE IT

When an object variable attribute may be omitted, declare it with `optional(<TYPE>, <DEFAULT>)`; Packer uses its default when the field is omitted.

variable "<name>" { type = object({ <attribute> = optional(<TYPE>, <DEFAULT>) }) }

WHY THIS HELPS

When declaring a Packer object variable with attributes that may be omitted, assign defaults to those attributes with `optional()`.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.16.0
  • optional(<TYPE>, <DEFAULT>): Marks an object type attribute as optional and supplies its default when omitted.
  • Prerequisite: Use Packer v1.16.0 or later; this feature is stated in the v1.16.0 release notes.
  • Omitted fields are supported when they have a default set.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card