'Is timestamp function not supported in HCL2?

I am trying to get the current day and put in a local

locals {
  current_day = formatdate("DD/MM/YYYY", timestamp())
}

but a I get this error Call to unknown function; There is no function named "timestamp". Is timestamp function not supported in HCL2 anymore? Is there any other way to get the current day?



Solution 1:[1]

It is working for me in the current version of HCL as of May 2022.

It appears that was not possible/was a bug in the version of HCL you were using. Here is a GitHub issue that few mentions functions not working in variables at the time:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MikeSchinkel