Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when applying plan when undeclared variables exist #36017

Closed
jbardin opened this issue Nov 15, 2024 · 2 comments · Fixed by #36025
Closed

error when applying plan when undeclared variables exist #36017

jbardin opened this issue Nov 15, 2024 · 2 comments · Fixed by #36025
Assignees
Milestone

Comments

@jbardin
Copy link
Member

jbardin commented Nov 15, 2024

#35903 doesn't take into account the presence of undeclared variables, so when any automatically applied variable files exist in the configuration directory, apply can't proceed.

Reproduction: apply any configuration which has a terraform.tfvars or *.auto.tfvars* file with a variable assignment not declared in the configuration.

@jbardin jbardin added the core label Nov 15, 2024
@jbardin jbardin added this to the v1.10 milestone Nov 15, 2024
@jbardin jbardin added the v1.10 label Nov 15, 2024
@bschaatsbergen
Copy link
Member

bschaatsbergen commented Nov 16, 2024

In addition to automatically applied variable files, a "Value for undeclared variable" error diagnostic is also thrown when a named file is used. This now happens when there's an undeclared variable declaration: https://github.com/hashicorp/terraform/blob/main/internal/backend/local/backend_apply.go#L272-L285.

We already produce warning diagnostics for undeclared variables when parsing variables values: https://github.com/hashicorp/terraform/blob/main/internal/backend/local/backend_local.go#L194 - which makes me believe we no longer need the first diagnostic I've linked to. However, this is only part of the issue—the error message you’re seeing comes from when a set variable cannot be found in the list of declared variables in the root module configuration, causing this else and error diagnostic to trigger.

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants