You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling terraform validate or terraform apply ends up with error message like this:
→ terraform validate
Error: Invalid expanding argument value
on locals.tf line 19, in locals:
19: subnets = cidrsubnets(var.vpc_cidr, local.newbits...)
The expanding argument (indicated by ...) must be of a tuple, list, or set
type.
Steps to Reproduce
terraform validate
terraform apply also fails.
Additional Context
I'm converting a list of strings into a list of numbers. Then, I'm concatenating three lists of numbers, so that they make a bigger list of numbers. Then I'm passing the long list of numbers as numbits to cidrsubnets and expanding it, as cidrsubnets does not accept the list by itself.
If I don't expand it - i.e. i use:
subnets=cidrsubnets(var.vpc_cidr, local.newbits)
i get following error with terraform apply:
→ terraform apply
Error: Invalid function argument
on locals.tf line 19, in locals:
19: subnets = cidrsubnets(var.vpc_cidr, local.newbits)
|----------------
| local.newbits is tuple with 9 elements
Invalid value for "newbits" parameter: number required.
So it sees it's a tuple, but then refuses to do the expansion.
Also, I fund this terraform module: https://github.com/hashicorp/terraform-cidr-subnets/blob/master/main.tf where it follows similar approach, but with variables instead of locals. I tried it, and then it passes validation correctly. Looks like terraform fails to infer type of a local value in some cases (expansion) but it can infer it in other cases (when I don'd attempt expansion it says it's a tuple).
References
The text was updated successfully, but these errors were encountered:
Hi @mkielar! Sorry for this odd behavior, and thanks for the straightforward reproduction case.
I think you've hit the same underlying bug as #24699 here. I believe this is actually an interaction between two different bugs:
The HCL interpreter's handling of ... fails with this error when it's given an argument whose type is not decidable yet. The normal cause of that is when it's a resource output whose type will not be decided until the apply step, but that doesn't apply in your case and so that brings us to the other bug...
...for some reason I've not yet determined, the concat function seems to be indicating that it cannot predict its result type, and thus triggering the above described behavior.
The first of the bugs above applies to both this one and#24699. The second one is unique to this particular issue, though fixing the first one would make the second one less important because it would change from being an error to just producing incomplete type information that could cause downstream validation to be skipped.
I think the fix over in HCL would be to add a new case to the switch statement that returns this error for if expandVal.Type() is cty.DynamicPseudoType, which is what it would return if the type isn't known yet. In that case, the function should immediately return cty.DynamicVal, diags and not attempt to execute the function yet. That will then allow the initial validation to succeed, so that later on the function call can be attempted again with full type information and produce the actual result.
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.
ghost
locked and limited conversation to collaborators
Jul 4, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bugconfirmeda Terraform Core team member has reproduced this issuev0.12Issues (primarily bugs) reported against v0.12 releases
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
cidrsubnets
should return a list of 9 subnets.Actual Behavior
Calling
terraform validate
orterraform apply
ends up with error message like this:Steps to Reproduce
terraform validate
terraform apply
also fails.Additional Context
I'm converting a
list
of strings into alist
of numbers. Then, I'mconcat
enating three lists of numbers, so that they make a biggerlist
of numbers. Then I'm passing the longlist
of numbers asnumbits
tocidrsubnets
and expanding it, ascidrsubnets
does not accept the list by itself.If I don't expand it - i.e. i use:
i get following error with
terraform apply
:So it sees it's a tuple, but then refuses to do the expansion.
Also, I fund this terraform module: https://github.com/hashicorp/terraform-cidr-subnets/blob/master/main.tf where it follows similar approach, but with variables instead of locals. I tried it, and then it passes validation correctly. Looks like terraform fails to infer type of a local value in some cases (expansion) but it can infer it in other cases (when I don'd attempt expansion it says it's a tuple).
References
The text was updated successfully, but these errors were encountered: