mirror of https://github.com/pulumi/pulumi.git
0d458a47df
### Description
Often when converting terraform modules such as tf VPC module, the range
expression of resources is a conditional expression of the form `if
should_create_resource ? N : 0`.
These expressions resolve their type to one of `int`, `bool`,
`Output[int]` or `Output[bool]`. Any other type we assume we are dealing
with a collection that we are trying to iterate over. However if the
conditional expression resolves to `optional(int)` then we think it is a
collection, try to get it's key-value pair types and error with "cannot
iterate over a value of type number"
This PR fixes this problem by unwrapping `int` from `optional(int)` when
encountered in these range expressions.
I was able to isolate a subset of the converted PCL from terraform VPC
module where this problem occurs and created a unit test from it.
Interesting note is that this only occurs in _non-strict_ mode 🤔 in
strict mode, the expression type from `range` is not optional. I've not
been able to find out why that is the case yet.
|
||
---|---|---|
.. | ||
asset | ||
authhelpers | ||
backend | ||
cmd/pulumi | ||
codegen | ||
display | ||
engine | ||
graph | ||
importer | ||
operations | ||
resource | ||
secrets | ||
testing/integration | ||
util | ||
version | ||
workspace | ||
README.md | ||
go.mod | ||
go.sum |
README.md
pulumi/pkg
While pulumi/sdk maintains strict backwards compatibility guarantees, code under pkg/ is handled more informally: while breaking changes are still discouraged they may happen when they make sense.