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.
|
||
---|---|---|
.. | ||
cgstrings | ||
convert | ||
docs | ||
dotnet | ||
gen_program_test | ||
go | ||
hcl2 | ||
nodejs | ||
pcl | ||
python | ||
report | ||
schema | ||
testing | ||
README.md | ||
docs.go | ||
docs_test.go | ||
programs.md | ||
sdks.md | ||
utilities.go | ||
utilities_test.go | ||
utilities_types.go |
README.md
(codegen)= (crosscode)=
Code generation
Code generation is essential to Pulumi's ability to support both a variety of programming languages and a variety of cloud providers. This package defines the core components of Pulumi's code generation functionality (known as Pulumi CrossCode). At a high level, code generation is used to manage three categories of output: SDKs, programs, and documentation. At a lower level, these all make use of a number of shared concepts such as schema and Pulumi Configuration Language (PCL).
:::{toctree} :maxdepth: 1 :titlesonly:
/pkg/codegen/sdks.md /pkg/codegen/programs.md /pkg/codegen/docs/README /pkg/codegen/schema/README /pkg/codegen/pcl/README :::