Repository navigation
feat: Adds DiffSuppressFunc and DiffSuppressOnRefresh to resources that have etag properties to suppress etag-related diffs - #2840
Conversation
…e etag properties to suppress etag-related diffs
usmonster
left a comment
There was a problem hiding this comment.
✅ LTGM (though I have no authority here 😄)
|
Sorry for digging old PRs, but we struggle with this in our PR automation.
Even though we're using 6.11, we see a lot |
|
@Wirone Could you share DEBUG logs of a plan to help us narrow it down? |
|
@deiga it's in our company's proprietary project for IaaC, so it may be hard to share it as it contains a lot of information about the infra even in INFO mode... But in short: today I added 6 |
@Wirone i get that it can be daunting to share something. Would you be able to use targeting to only one of these resources on DEBUG level? That could be enough to follow where the code is going. |
|
I will try to do it 👍. |
… fields PR integrations#2840 added etag diff suppression to 7 resources but missed the remaining 22. This causes spurious diffs on every plan/apply for resources like github_team, github_membership, github_team_repository, github_repository_deploy_key, and others. Apply the same pattern (Optional + DiffSuppressFunc returning true + DiffSuppressOnRefresh) to all remaining resource etag schema fields and extend the unit test to cover all 29 resources. Fixes integrations#3103 Fixes integrations#3291 Co-Authored-By: Claude <[email protected]>
etag is server-computed and should not be user-editable. Remove Optional: true from all etag schema fields (both the 22 new ones and the 7 from PR integrations#2840) and update the unit test accordingly. Co-Authored-By: Claude <[email protected]>
Resolves #796
Before the change?
After the change?
Details from #796
Initially an approach was made but the implementation was incomplete due to needing to support update. 4 years later we're on a newer version of the SDK (terraform-plugin-sdk/v2 v2.34.0) that supports
DiffSuppressOnRefreshWe should now be able to go with the initial approach (even on computed fields) of:
And add
DiffSuppressOnRefresh: trueas well to suppress the diff between config and state.Lastly these fields have to be marked as optional=true - SDK ref
I believe we can set this to always returns true - which should suppress all etag diffs; this should also work for refresh operations as well.
This approach should be safe because ETags are internal concerns, not user configuration, ETags are still stored and used for API optimization by the SDK / provider, and all user changes to actual resource attributes are still detected normally.
Let me put a quick PR together to illustrate this and see if everyone agrees with the approach. The better move would be to migrate to the Plugin Framework but for now we can get this cleaned up a bit as is.
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!