Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform destroy calls CustomizeDiff though documentation suggests it shouldn't be #1122

Open
prashantv opened this issue Jan 9, 2023 · 1 comment
Labels
bug Something isn't working tf-devex-triage Terraform DevEx project tracking

Comments

@prashantv
Copy link

SDK version

v2.24.1

Relevant provider source code

https://github.com/prashantv/terraform-customizediff-on-destroy-repro

Terraform Configuration Files

Config doesn't matter, as it seems to always happen. However, the above repo does contain a repro with config.

Debug Output

https://gist.github.com/prashantv/5e00eb5e6dc9215c280d7cb30a68cf26

Expected Behavior

CustomizeDiff shouldn't be called, as documented in the SDK docs.

// * Destroy: No runs (standard diff logic is skipped on destroy diffs)

If it is called, there should be some way for the provider to know that this is a destroy call.

Actual Behavior

CustomizeDiff is called.

Steps to Reproduce

See https://github.com/prashantv/terraform-customizediff-on-destroy-repro

@prashantv prashantv added the bug Something isn't working label Jan 9, 2023
@prashantv
Copy link
Author

prashantv commented Jan 10, 2023

It looks like the CustomizeDiff is called due to the refresh step (which TF internally does using plan).

Using terraform destroy -refresh=false doesn't cause CustomizeDiff to be called.

However, as a provider developer, we can't tell users to avoid refresh (and shouldn't since there's a benefit to the refresh). Ideally the plugin SDK is responsible for handling this, as there doesn't seem to be a clear way to identify that a CustomizeDiff is happening as part of a destroy step.

@bflad bflad added the tf-devex-triage Terraform DevEx project tracking label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tf-devex-triage Terraform DevEx project tracking
Projects
None yet
Development

No branches or pull requests

2 participants