hashicorp / hashicorp/packer

local variables are evaluated before their dependencies from data source have been computed

Open
#13,299 12 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) 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 have a complex packer build "script", where i have a data source that fetches data from a website. I then have `locals` sections with local variables that reference this data source, and these locals are then referenced in other locals, which in turn are referenced in builders.

I'm seeing that sometimes the builds/sources are evaluating the locals before the root data source has been started, resulting in e.g.:

`This object does not have an attribute named "vm_name".`

I would have expected any evaluation of expressions like `vm_name = local.vm_name` on a source to be deferred until all the dependent variables, including data sources, have been resolved. Is this not the case?

### Packer version

Packer v1.12.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.