backend/local: Show resource instance drift as part of the plan #26921
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For another installment of "I had a little extra time at the end of the week", I noticed a few weeks ago that we now have sufficient information available during planning to detect and report drift explicitly, like we mocked in #15419. This is a prototype of that, mainly focused on seeing what the real UX might be like and how the problem has changed since I filed #15419.
When a user edits Terraform-managed objects outside of Terraform it can often prove confusing because Terraform indicates the need to change something even though the configuration hasn't changed.
We retain enough information in the state that we can actually detect when an object has "drifted" since the last apply, so now we'll include that information in the plan output both just to generally make it more visible (in case the drift wasn't actually intentional and so investigation is warranted) and also to potentially serve as an explanation for other changes that appear in the plan that follows.
One way this problem changed since I wrote up #15419 is that we've made sure that
terraform plan
will consider changes to root module outputs as needing to be applied, which was actually the main motivation for #15419, and we've also refined how data resources work so they get processed as part of planning now too.Because of that, I no longer think it's important to be able to "apply" drift into the state in isolation, if that drift doesn't result in changes to the outputs. Applying it would not result in any significant observable side-effect. With that said, this prototype is therefore just a cosmetic UI thing and doesn't cause Terraform to consider drift as changes to be applied, only as extra context to present alongside changes to be applied.