hashicorp / terraform-plugin-sdk

Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions
https://developer.hashicorp.com/terraform/plugin
Mozilla Public License 2.0
425 stars 230 forks source link

feat(terraform): add ability to suppress github etag while being noisy when no actual state has been changed #1355

Closed aamkye closed 3 days ago

aamkye commented 6 days ago

Issues and PRs reference:

The ETags are shown in diff on almost every plan, even after apply just before the next plan. After this change, ETag diff disappears. I've also added tests.

hashicorp-cla-app[bot] commented 6 days ago

CLA assistant check
All committers have signed the CLA.

hashicorp-cla-app[bot] commented 6 days ago

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

aamkye commented 6 days ago

@catsby could you look at this? :)

austinvalle commented 3 days ago

Hey there @aamkye 👋🏻 , sorry you're running into trouble with the GitHub provider etag diffs.

Unforuntately, we won't be able to accept this contribution as this SDK is used by all Terraform providers. Computed attributes have no practical use with DiffSupressFunc as the main intention of that function is to prevent inconsequential differences between "config" and prior state. Computed attributes aren't defined in config, which is why that original PR in the GitHub provider caused an internal validation error.

Looking briefly through the GitHub provider issues, it seems like the intended usage of the etag is for internal use by the provider, so the ideal solution would be to use private state to store that etag. That way, users can't reference etag, any drift in the value would not be reported to users, and the provider would still be able to reference that value for caching purposes.

Unfortunately, it seems like the GitHub provider resources referenced here are written in the older terraform-plugin-sdk/v2, which doesn't support private state. We don't have any plans to introduce private state to the older SDK, so the only way forward would be to migrate the GitHub provider resources over to terraform-plugin-framework. I see there is an open issue to start that migration here: https://github.com/integrations/terraform-provider-github/issues/1912