-
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
conditional expression unknown with inferred types #21745
Comments
Hi @voodoodror, Thanks for filing the issue! What I discovered so far, is that this appears to be somehow caused by the conversion of the conditional with lists to a set type in the resource config. Assigning the conditional to a list attribute directly works as expected, as does removing the conditional. |
Hi @jbardin, Thanks for uploading fix for this issue. Unfortunately I can confirm that the problem still present in Terraform v0.12.4. This is the
While trying to come up with a solution, I've tried converting the variable from map of lists to map of strings (using Terraform v0.12.4):
I can confirm that it works the same way I would expect it be, but it seems like a very clumsy workaround. It can be clearly seen that there's an issue with map of lists variables. |
Hi @voodoodror, Thanks for the update. The original issue I found does seem to be fixed, but the result you're getting is the same for another reason. The type of the map in your configuration is not precise, and due to a combination of the unknown final type of both maps, and the fact that one of the maps does not contain the possible key for evaluation, the expression result is unknown during plan. Specifying the variable types fully will allow the expression to return a known type:
I think we can still do better at handling the inferred situation though, and I'm going to repoen this as a slightly different issue. |
Without explicit types, the inferred value of the variable here is:
And if the key does not exist, the returned value is |
Many thanks @jbardin ! Now it definitely works as it should. I guess I somehow missed the documentation part that explains about declaring map of various types. |
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
random.tf
random.tfvars
Debug Output
Expected Behavior
Terraform plan should return "No changes" if no real changes were made.
Actual Behavior
Steps to Reproduce
Thanks!
The text was updated successfully, but these errors were encountered: