pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
194 stars 43 forks source link

Pulumi-inexpressible values after MaxItemsOne flattening under ConfigModeAttr #2025

Open VenelinMartinov opened 4 months ago

VenelinMartinov commented 4 months ago

What happened?

Combining MaxItemsOne with ConfigModeAttr yields inexpressible values in pulumi land because of MaxItemsOne flattening.

Azure classic is a provider which uses ConfigModeAttr quite a bit so might be a good place to look for examples of real world usage.

Example

schema:

"f0": {
    Optional:   true,
    Type:       schema.TypeList,
    MaxItems:   1,
    ConfigMode: schema.SchemaConfigModeAttr,
    Elem: &schema.Resource{
        Schema: map[string]*schema.Schema{
            "x": {Optional: true, Type: schema.TypeString},
        },
    },
}

in terraform we can pass:

resource "crossprovider_testres" "example" {
  f0 = []
}

but on pulumi side we can either not specify it, pass x=nil or x=non-nil.

These map to nil, nil, and non-nil respectively but none of them map to [].

Output of pulumi about

.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

t0yv0 commented 2 months ago

Yes, somewhat of a known unfortunate issue, thanks for documenting this. This would benefit from fully worked examples and impact. For an attribute of this type:

TF has 5 unknown, nil, [], [{"foo": "bar"}] states.

Pulumi has 4 unknown, nil, {"foo": "bar"} states.

We cannot turnaround or map 1:1, but we can decide whether Pulumi nil should map to nil or to [], how does it map currently, and what are the trade-offs.