-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Invalid argument name when upgrading to 0.12 #22901
Comments
Hi @Edeholland! This configuration seems to be relying on some undocumented behavior that changed in Terraform 0.12. The configuration was invalid in Terraform 0.11 too, but some different implementation details caused Terraform 0.11 to not detect it. (Internally, this was because Terraform 0.11 relied entirely on provider logic for validation, while Terraform 0.12 includes its own validation step that runs during static validation regardless of the provider's validation behavior.) The only way to make this work in Terraform 0.12 is to remove the invalid argument name. It looks like what you are looking for here is the feature being discussed in #2847, in which case we'd suggest that you vote 👍 on that issue and watch it for future updates. In the mean time, you could get a similar result (failing if the tier is invalid) in this case by accessing the tiers through an "identity map" that just maps the valid keys to themselves: locals {
tiers = {
group = "group"
app = "app"
}
selected_tier = local.tiers[var.tier] # If this fails, the tier variable is invalid
} If you access the tier as Since #2847 is already covering the use-case, we're going to close this out to consolidate the discussion. Thanks! |
Thanks for the explanation, I got my code working now! |
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. |
Terraform Version
Terraform Configuration Files
Expected Behavior
Configuration should be valid.
Actual Behavior
Steps to Reproduce
terraform init
terraform apply
Additional Context
I tried running
terraform 0.12upgrade
. This resulted in the following error:Is there any way I can keep the variable name I have now when upgrading from 0.11 to 0.12?
The text was updated successfully, but these errors were encountered: