terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
Add handling for destroy errors
I'm not sure exactly how to test this, it would be easy to try it out in my local env if I could branch off the main repo instead of my fork as the module namespacing breaks everything.
There's likely a workaround for doing this, please lmk.
Hi @matthewcummings 👋 Thank you for submitting this.
Before we discuss any potential implementation details, let's continue the discussion in #609 to determine if and what should be done. The testing framework has long tried to prevent provider developers from purposefully creating situations which can leave dangling infrastructure that would require manual cleanup. If there's a bug when trying to use Destroy: true and ExpectError in the same TestStep, then that's likely a bug that should be resolved differently than introducing another field to the mix.
it would be easy to try it out in my local env if I could branch off the main repo instead of my fork as the module namespacing breaks everything
You may find using the go mod edit -replace command handy for this situation in a provider to override the location of the github.com/hashicorp/terraform-plugin-sdk/v2 temporarily, e.g. for a local path:
go mod edit -replace github.com/hashicorp/terraform-plugin-sdk/v2=/path/to/local/terraform-plugin-sdk
Or remote reference:
go mod edit -replace github.com/hashicorp/terraform-plugin-sdk/v2=github.com/matthewcummings/terraform-plugin-sdk@check-destroy-error-handler
To undo it, the replace directive can be removed from the go.mod file or the go mod edit -dropreplace command can be used.
Thanks for the suggestion @bflad. I will hold off for now until a decision is made to consider this enhancement or not per the discussion in #609
FWIW, it was not a simple path/import replacement across all the .go files, I started down that path and hit nested import issues with the code in /internal.
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.