Packer HCL2 RFC 3339 and Unix timestamp parsing functions
Introduced 2026-07-24 · score 0.96
HOW TO USE IT
When a Packer HCL2 template needs to parse a timestamp, choose the function for the input format. Use `rfc3339_parse(<RFC3339 timestamp>)` for RFC 3339 input; use `unix_timestamp_parse(<RFC3339 timestamp or Unix epoch integer>)` for either format.
locals {
parsed = rfc3339_parse("<RFC3339 timestamp>")
}locals {
parsed = unix_timestamp_parse(<RFC3339 timestamp or Unix epoch integer>)
}WHY THIS HELPS
When a Packer template needs to parse a timestamp, use the HCL2 timestamp parsing function that matches the input format.
REQUIREMENTS AND LIMITATIONS
- Version: v1.16.0
- rfc3339_parse(timestamp) (required): Takes an RFC 3339 timestamp string; returns date fields and a `unix` attribute.
- unix_timestamp_parse(timestamp) (required): The v1.16.0 release note says it accepts an RFC 3339 timestamp or Unix epoch integer. Returns date fields and an RFC 3339 representation, per the implementation PR.
- Both functions accept RFC 3339 timestamps; `unix_timestamp_parse` additionally accepts Unix epoch integers.
- Docs conflict: The implementation PR describes `unix_timestamp_parse(unix_timestamp number)` as taking an epoch integer; the v1.16.0 release note says it also accepts RFC 3339 timestamps. Follow the release note's broader input support.
FIRST-PARTY EVIDENCE
- https://github.com/hashicorp/packer/releases/tag/v1.16.0
- https://github.com/hashicorp/packer/pull/13669
Check the installed version and the source before using it. Entry JSON