pulumi / pulumi-terraform-bridge

A library allowing providers built with the Terraform Plugin SDK to be bridged into Pulumi.
Apache License 2.0
184 stars 42 forks source link

Bridge does not run TF upgrades from version 0 -> 1 #2039

Closed VenelinMartinov closed 2 days ago

VenelinMartinov commented 1 month ago

What happened?

While working on https://github.com/pulumi/pulumi-terraform-bridge/issues/2034, it was discovered that TF runs state upgrades for a resource created with version 0 and then upgraded to 1, while we don't seem to.

I believe this is because version 0 is not written to state and we assume current version, while TF assumes 0.

Example

.

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).

VenelinMartinov commented 1 month ago

repro in https://github.com/pulumi/pulumi-terraform-bridge/pull/2040

t0yv0 commented 3 weeks ago

Haven't had time to check if still an issue with the latest version that passed AWS tests https://github.com/pulumi/pulumi-aws/pull/4013

VenelinMartinov commented 2 weeks ago

Confirmed this is indeed still an issue.

VenelinMartinov commented 2 weeks ago

Yeah, I ran the repro with some debug logs and it looks like on the first pulumi up, everything is fine but we don't write version 0 to state.

After that when getting the state and transforming to TF state https://github.com/pulumi/pulumi-terraform-bridge/blob/3c1421d15a61cfa11f350db7b796dcd5795da200/pkg/tfbridge/schema.go#L1308

we assume empty schema version means current version, so we don't run the state upgrade.

We have two ways forward:

  1. ensure we write version 0 to state
  2. stop assuming current version

2 is what TF does so I'll try that.

VenelinMartinov commented 2 weeks ago

This seems to affect non-PRC too