terraform-plugin-sdk icon indicating copy to clipboard operation
terraform-plugin-sdk copied to clipboard

Add handling for destroy errors

Open matthewcummings opened this issue 3 years ago • 5 comments

matthewcummings avatar Jun 03 '22 03:06 matthewcummings

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Jun 03 '22 03:06 hashicorp-cla

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.

matthewcummings avatar Jun 04 '22 15:06 matthewcummings

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.

bflad avatar Jun 14 '22 23:06 bflad

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

matthewcummings avatar Jun 15 '22 13:06 matthewcummings

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.

matthewcummings avatar Jun 19 '22 14:06 matthewcummings

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.

github-actions[bot] avatar Oct 28 '22 02:10 github-actions[bot]