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.
|
||
---|---|---|
.. | ||
README.md | ||
binder.go | ||
binder_component.go | ||
binder_nodes.go | ||
binder_resource.go | ||
binder_resource_test.go | ||
binder_schema.go | ||
binder_schema_test.go | ||
binder_test.go | ||
component.go | ||
config.go | ||
diagnostics.go | ||
functions.go | ||
functions_test.go | ||
intrinsics.go | ||
invoke.go | ||
local.go | ||
output.go | ||
program.go | ||
resource.go | ||
rewrite_apply.go | ||
rewrite_apply_test.go | ||
rewrite_convert.go | ||
rewrite_convert_test.go | ||
rewrite_properties.go | ||
type.go | ||
utilities.go | ||
utilities_test.go |
README.md
(pcl)=
Pulumi Configuration Language (PCL)
Pulumi Configuration Language (PCL) is an internal representation of Pulumi programs which supports all core concepts of the Pulumi programming model in a minimal form. Although not exposed directly to users today, this intermediate representation is used to support a variety of program conversion tasks, from and to various supported Pulumi languages.