mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-12 09:01:33 -04:00
Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Signed-off-by: Roman Grinovski <roman.grinovski@gmail.com> Co-authored-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Co-authored-by: Roman Grinovski <roman.grinovski@gmail.com>
53 lines
1.7 KiB
Plaintext
53 lines
1.7 KiB
Plaintext
---
|
|
sidebar_label: plantimestamp
|
|
description: |-
|
|
The plantimestamp functions a string representation of the date and time
|
|
during the plan.
|
|
---
|
|
|
|
# `plantimestamp` Function
|
|
|
|
`plantimestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format.
|
|
|
|
In the OpenTofu language, timestamps are conventionally represented as
|
|
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
|
"Date and Time format" syntax, and so `plantimestamp` returns a string
|
|
in this format.
|
|
|
|
The result of this function will change for every plan operation. It is intended
|
|
for use within [Custom Conditions](../../language/expressions/custom-conditions.mdx)
|
|
as a way to validate time sensitive resources such as TLS certificates.
|
|
|
|
There are circumstances, such as during an OpenTofu [Refresh-only](../../cli/commands/plan.mdx#planning-modes) plan, where
|
|
the value for this function will be recomputed but not propagated to resources
|
|
defined within the configuration. As such, it is recommended that this function
|
|
only be used to compare against timestamps exported by providers and not against
|
|
timestamps generated in the configuration.
|
|
|
|
The `plantimestamp` function is not available within the OpenTofu console.
|
|
|
|
## Examples
|
|
|
|
```
|
|
> plantimestamp()
|
|
2018-05-13T07:44:12Z
|
|
```
|
|
|
|
```hcl
|
|
check "opentofu_org_certificate" {
|
|
data "tls_certificate" "opentofu_org" {
|
|
url = "https://www.opentofu.org/"
|
|
}
|
|
|
|
assert {
|
|
condition = timecmp(plantimestamp(), data.tls_certificate.opentofu_org.certificates[0].not_after) < 0
|
|
error_message = "opentofu.org certificate has expired"
|
|
}
|
|
}
|
|
```
|
|
|
|
## Related Functions
|
|
|
|
* [`timestamp`](../../language/functions/timestamp.mdx) returns the current timestamp when it is evaluated
|
|
during the apply step.
|