The timestamp() function in the interpolation syntax will return an ISO 8601 formatted string, which looks like this 2019-02-06T23:22:28Z
. However, I want to have a
Terraform 0.12.0 introduced a new function formatdate which can make this more readable:
output "timestamp" {
value = formatdate("YYYYMMDDhhmmss", timestamp())
}
At the time of writing, formatdate
's smallest supported unit is whole seconds, so this won't give exactly the same result as the regexp approach, but can work if the nearest second is accurate enough for the use-case.