-
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
Looks like True and False expression types should not match in all cases? #14399
Comments
Happening for me as well with:
|
+1 |
If you need other examples, I have the same problem with:
|
Same problem here :
|
Trace log shows the following interesting bits:
|
I think this is some fallout from #14135. We're missing the special case of making the conditional return unknown ("computed", to use the terminology from the UI) if either one of its values is unknown, so we're falling through to the usual type check, which then produces this error. |
In #52 we relaxed the rule that any unknown value would immediately cause an early exit, which in turn requires the type checker for each node to specifically deal with unknown values. However, we missed dealing with the check that both types match in a conditional, causing a conditional to fail if either side of it is unknown. This causes errors in Terraform, as described in hashicorp/terraform#14399.
hashicorp/hil#53 addresses a regression with type checking of unknown values in the HIL conditional operator. This fixes #14399.
Hi all! Sorry for this regression. I have opened #14454 to merge in the upstream fix from the interpolation language parser that should clear this up. Until this gets merged and released, a workaround is to use a So in @pikeas's case, for example, this might be:
Once the resource has been created its computed attributes will be known and so Terraform should then be able to evaluate the conditional expression as expected. |
hashicorp/hil#53 addresses a regression with type checking of unknown values in the HIL conditional operator. This fixes #14399.
Also seeing this on 0.9.5 when using a conditional with a rendered template as one branch and literal string as the other. Work around, wrap the rendered template with |
Ahh, good idea on that workaround, @wr0ngway! Any function that returns a string should work similarly. This is now merged, so we'll get this fixed properly in 0.9.6. The |
We seem to be hitting hashicorp/terraform#14399
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 v0.9.5
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Should works. It works if I use Terraform v0.9.4
Actual Behavior
Steps to Reproduce
terraform plan
Additional info.
Just for test I used the same expression types for true and false:
It will works If I will change ami to:
or
The text was updated successfully, but these errors were encountered: