-
Notifications
You must be signed in to change notification settings - Fork 50
Description
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.
-
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#L289This 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-L38C1InstanceDiff.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. -
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:
- makeDetailedDiff distorts the plan incorrectly deciding whether there are changes or not #1501
- Refer to Terraform diff to generate a more precise diff #1499 attempt to fix
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).