Closed zfouts closed 4 years ago
Hi thanks for reaching out. The PKR_VAR
prefix is a requirement to ensure proper variable handling in HCL2 enabled templates. @azr did a great job explaining it here.
I'm going to close this issue as it has already been answered. But if you think we can improve the documentation a bit to call out the requirement. Reach out with the suggestion and we will gladly make the update.
We spent some time discussing this option internally and decided to reverse course on our decision -- you'll be able to use an env function in HCL once https://github.com/hashicorp/packer/pull/10240 is merged.
Fantastic news!
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.
Please search the existing issues for relevant feature requests, and use the reaction feature (https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to add upvotes to pre-existing requests.
Community Note
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 "me too" comments, 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.
Description
HCL2 seemingly does not support using standard system environment variables without resetting them to
PKR_VAR_<NEW_ENV>
.For example, with JSON you can do the following:
With the template conversion, it creates the following:
Results in the following error:
Variables may not be used here.
Use Case(s)
Being able to utilize standard env vars from your system without having to set some packer specific environment variable such as
PKR_VAR_BLAH
would be more than beneficial.Potential configuration
Potentially allow for a ${env.Foo} setting within the variable block, such as:
Potential References
https://discuss.hashicorp.com/t/hcl2-environment-variables/9290