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
Previously for JSON legacy templates the use of variable definition files containing one or more variables that were not declared in the "variables" JSON property Packer would execute without warning. The same build using HCL templates warn for undeclared variables. The only option for silencing the warnings is to defined the variable within the template with a default value, which is confusing if the variable is not used anywhere in the template; this is issue is greatly amplified when the variable definition file contains many unused variables for the said template.
Use Case(s)
When using a shared variables definition file that is used as an input to multiple template files it would be great to have an option for disabling the warning for undeclared variables within a var-file. Having to update each of the templates with default values for the unused variables is tedious and confusing for users looking at the template that contains a bunch of declared but unused variables.
~> packer build -var-file=/tmp/shared.json /tmp/build.pkr.hcl
Warning: Undefined variable
A "region" variable was set but was not declared as an input variable. To
declare variable "region", place this block in one of your .pkr.hcl files, such
as variables.pkr.hcl
variable "region" {
type = string
}
null.example: output will be in this color.
==> null.example: Running local shell script: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer-shell3565688691
null.example: Running a build as nywilken
Build 'null.example' finished after 139 milliseconds 711 microseconds.
==> Wait completed after 139 milliseconds 761 microseconds
==> Builds finished. The artifacts of successful builds are:
--> null.example: Did not export anything. This is the null builder
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
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.
Description
Previously for JSON legacy templates the use of variable definition files containing one or more variables that were not declared in the
"variables"
JSON property Packer would execute without warning. The same build using HCL templates warn for undeclared variables. The only option for silencing the warnings is to defined the variable within the template with a default value, which is confusing if the variable is not used anywhere in the template; this is issue is greatly amplified when the variable definition file contains many unused variables for the said template.Use Case(s)
When using a shared variables definition file that is used as an input to multiple template files it would be great to have an option for disabling the warning for undeclared variables within a var-file. Having to update each of the templates with default values for the unused variables is tedious and confusing for users looking at the template that contains a bunch of declared but unused variables.
Potential configuration
shared-variables.json
build.pkr.hcl
Potential References
Relevant discussion :#12020 (comment)
The text was updated successfully, but these errors were encountered: