pulumi / pulumi-terraform-bridge

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

[Plugin Framework] Support computing DetailedDiff in Diff method for best CLI experience #752

Open t0yv0 opened 1 year ago

t0yv0 commented 1 year ago

Initially we couldn't find examples where this results in a meaningful UX improvement but there are actually such examples. We're observing diffs that don't explain to the user at all why the diff is happening right now. For completeness sake we should implement detailed diff to expose as much information as we have to the CLI UI.

t0yv0 commented 1 year ago

I've done some experiments on pulumi-random comparing the behaviors of 4.10.0 (pre PF) and 4.13.2 (PF). This program:

import * as pulumi from "@pulumi/pulumi";
import * as r from "@pulumi/random";

const pet = new r.RandomPet(
    "monkey", {
        keepers: {
            "special": "boom1", // "boom2"
        }
    }
);

export const pid = pet.id;

Both respond to pulumi preview --diff with:

      ~ id       : "stirred-bullfrog" => output<string>
      ~ keepers  : {
          ~ special: "boom1" => "boom2"
        }

So it appears that the engine is able to render nested property diffs - at least in simple cases - even if the provider does not populate DetailedDiff property in the response to the Diff method.

That was the one use case I had in mind when writing this issue.

I'd like to close this as won't fix for now until we understand what other use cases do not work as expected and why we'd want to implement DetailedDiff for PF-based providers..

t0yv0 commented 10 months ago

I'm going to reopen this based on a recent conversation on what this method does for SDKv2 providers. https://github.com/pulumi/pulumi-terraform-bridge/issues/1504

The method is important for usability as it can expose TF-level information about which property caused a replacement, as well as highlight changes to the plan that come from TF diff customizers that are not visible to Pulumi engine. So there is some differential utility in having this method implemented.

t0yv0 commented 1 month ago

In retrospect this is necessary for Set collections to surface better.

t0yv0 commented 1 month ago

Looking to resolve this by integrating https://github.com/pulumi/pulumi-terraform-bridge/issues/2294 under a flag and rolling out as part of the epic.