Skip to content

Fix makeDetailedDiff inaccuracies #1504

@t0yv0

Description

@t0yv0

What happened?

Consider rewriting makeDetailedDiff for SDKv2 providers.

The objective of makeDetailedDiff is to extract useful information and expose it in the response to
the Diff method so that Pulumi CLI can surface better results to the user:

https://github.com/pulumi/pulumi/blob/master/proto/pulumi/provider.proto#L262

It can surface which paths have changed, as well as the nature of the change:

https://github.com/pulumi/pulumi/blob/master/proto/pulumi/provider.proto#L211

Since TF providers modify changes internally, and have the best information on which changes require
replacements, skipping makeDetailedDiff degrades the usability. The engine in Pulumi CLI will still
attempt to compute diffs but will fail to expose the accurate information only known to the
TF-bridged provider.

There are a few known issues with the current implementation.

  1. It claims that terraform.InstanceDiff cannot distinguish betwen add, delete and replace plans,
    and applies inaccurate heuristics in
    https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pkg/tfbridge/diff.go#L289

    This is not entirely accurate since the information is present, but difficult to correlate:
    https://github.com/hashicorp/terraform-plugin-sdk/blob/28e631776d97f0a5a5942b3524814addbef90875/terraform/diff.go#L38C1-L38C1

    InstanceDiff.Attribute uses "flatmap-style" keys that are difficult to interpret. Besides
    InstanceDiff, the provier has out of band information available on the prior state of the
    resource's Pulumi inputs and outputs, as well as the proposed new set of Pulumi inputs and
    outputs. If path correlation could be made to work correctly, the caller could be able to
    interpret any given change as Add/Update/Delete correctly.

  2. It is based on traversing Pulumi-level values which misses changes introduced by TF entirely.
    Changes may be coming from diff customizers, one example is applying default GCP labels or
    default tags in AWS. These changes introduce new paths that are currently skipped by
    makeDetailedDiff.

Example

Some back-history:

Output of pulumi about

N/A

Additional context

v3.63.2 affected.

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

Metadata

Metadata

Labels

bug/diffBugs in computing Diffs and planning resource changeskind/bugSome behavior is incorrect or out of specresolution/fixedThis issue was fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions