pulumi/changelog
Zaid Ajaj 0d458a47df
[program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569)
### 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.
2024-10-17 20:55:38 +00:00
..
pending [program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569) 2024-10-17 20:55:38 +00:00
config.yaml Make pulumi install work for policy packs (#16438) 2024-06-21 19:19:21 +00:00