You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Overview of the Issue
I am trying to use Packer's formatdate and timestamp functions to create a variable, eg.:
formatdate("YYYY-MM-DD", timestamp())
However, I can't seem to get these functions to work when using them to declare a variable. Attempting to declare the below variable:
Error: Call to unknown function
on variables.pkr.hcl line 48, in variable "testfunc":
48: default = formatdate("YYYY-MM-DD", timestamp())
on variables.pkr.hcl line 48, in variable "testfunc":
There is no function named "formatdate".
48: default = formatdate("YYYY-MM-DD", timestamp())
I only seem to be able to use packer's built-in functions if they are utilized in a local or locals block, so the below locals block works perfectly fine:
Can't imagine that this is by design, as I have seen other past issues that appear to also reference this issue, but are now closed (eg #9430 ). Not sure why the issue was closed, as the issue does not appear to have been fixed.
Reproduction Steps
Create a packer config file
define a variable and set the default value to use the timestamp function
Error: Call to unknown function
on variables.pkr.hcl line 48, in variable "testfunc":
48: default = formatdate("YYYY-MM-DD", timestamp())
on variables.pkr.hcl line 48, in variable "testfunc":
There is no function named "formatdate".
48: default = formatdate("YYYY-MM-DD", timestamp())
2023/08/07 20:14:51 [INFO] (telemetry) Finalizing.
There is no function named "formatdate".
2023/08/07 20:14:52 waiting for all plugin processes to complete...
The text was updated successfully, but these errors were encountered:
This is actually by design of the HCL language. In the issue you linked in your description the reason why that one was closed is found in this comment #9430 (comment). Variables are meant to be constant values and local variables are meant for computing a value. This separation is meant to keep it clear what is generated and what is provided by the caller.
Thanks for the assist @Stromweld. @youngturk2 I'm going to close this as it is not an issue with variables. But please feel free to reach out if you run into any other unexpected variable questions or behaviors.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Overview of the Issue
I am trying to use Packer's formatdate and timestamp functions to create a variable, eg.:
However, I can't seem to get these functions to work when using them to declare a variable. Attempting to declare the below variable:
Results in the below error message:
I only seem to be able to use packer's built-in functions if they are utilized in a local or locals block, so the below locals block works perfectly fine:
Can't imagine that this is by design, as I have seen other past issues that appear to also reference this issue, but are now closed (eg #9430 ). Not sure why the issue was closed, as the issue does not appear to have been fixed.
Reproduction Steps
Packer version
packer -version
1.9.2
Simplified Packer Template
Operating system and Environment details
Windows server 2016 x64
Log Fragments and crash.log files
The text was updated successfully, but these errors were encountered: