pulumi / pulumi-terraform-bridge

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

Support safely migrating from MaxItems=1 to no MaxItems #5

Open lukehoban opened 5 years ago

lukehoban commented 5 years ago

Today, all MaxItems:1 properties are projected as scalars instead of arrays. This is fine, but if the TF schema ever changes to remove this limitation (because the underlying resource beings accepting multiple items), then this will result in a breaking change in Pulumi that is not a breaking change in Terraform.

We could possibly handle this without a breaking change by:

  1. Identifying that this change happened (or alerting if the schema diff results in incompatibility)
  2. Allowing a property to be marked as supporting both singular and plural projections
  3. Manually or automatically deprecating the singular projection in these cases

For (2), this would likely involve allowing two different input properties on the Pulumi side to map to the same Terraform schema input, and making these two mutually exclusive from Pulumi. Then also exposing two output properties, one the scalar which gets automatically populated from [0] on the underlying resource, and the other the whole array from the underlying resource.

t0yv0 commented 1 year ago

Looking at this again with @iwahbe and team -

We might be identifying this as a breaking change in schema-tools already as of today, but we do not attribute it to MaxItemsOne in the output schema-tools produces.

Current approach is to automate withholding MaxItems=1 changes until next major release and then taking a break.

Supporting smooth migrations for every language like (2) seems a tad difficult especially for languages like Go. Java say could handle Union[T, List[T]] via overloads and be backwards compatible. But no sure how to do this in Go.

t0yv0 commented 1 year ago

https://github.com/pulumi/pulumi-terraform-bridge/issues/904 related

iwahbe commented 5 months ago

https://github.com/pulumi/pulumi-terraform-bridge/issues/1667 is a pre-requisite here.