Terraform timestamp() to numbers only string

前端 未结 3 896
难免孤独
难免孤独 2021-02-08 12:29

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

3条回答
  •  无人及你
    2021-02-08 13:00

    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.

提交回复
热议问题