Description
Terraform CLI and Provider Versions
Terraform v1.12.0
on windows_amd64
- provider registry.terraform.io/hashicorp/time v0.13.1
Use Cases or Problem Statement
Introduce a precision argument to the time_static resource to allow users to control the level of time granularity (e.g., seconds, milliseconds, microseconds) stored in the timestamp.
Currently, the time_static resource captures the exact time when it is first created and persists it across plans. However, the timestamp always includes full precision down to the second (e.g., 2023-10-05T13:24:36Z). In some use cases—such as deterministic outputs, integration with systems that only accept date-level precision, or comparing time strings—it would be useful to allow customization of the time format and granularity.
Proposal
Add an optional precision argument to the time_static resource with the following possible values (default: second
):
resource "time_static" "example" {
precision = "date" # or "second", "millisecond", "microsecond", "nanosecond"
}
Result values:
- "date" ->
2023-10-05
- "second" (default) ->
2023-10-05T13:24:36Z
- "millisecond" ->
2023-10-05T13:24:36.123Z
- "microsecond" ->
2023-10-05T13:24:36.123456Z
- "nanosecond" ->
2023-10-05T13:24:36.123456789Z
New read-only fields:
- millisecond (Number): the millisecond part 0–999
- microsecond (Number): the microsecond part 0–999999
- nanosecond (Number): the nanosecond part 0–999999999
- unix_milli (Number): milliseconds since epoch (e.g. 1581489373123)
- unix_nano (Number): nanoseconds since epoch (e.g. 1581489373123456000)
How much impact is this issue causing?
Medium
Additional Information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct