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

Configured destroy entrypoint (and body) not being invoked #116

Open
crandall-chow-bl opened this issue Feb 16, 2022 · 6 comments
Open

Configured destroy entrypoint (and body) not being invoked #116

crandall-chow-bl opened this issue Feb 16, 2022 · 6 comments
Labels
bug Something isn't working P4 low priority issues triaged Scoped and ready for work upstream Work required on Terraform core or provider

Comments

@crandall-chow-bl
Copy link

crandall-chow-bl commented Feb 16, 2022

TL;DR

The configured destroy_cmd_entrypoint and destroy_cmd_body are not being invoked, even though the logs show the destroy was triggered and resource was removed from the .tfstate.

Expected behavior

On "destroy" (such as when TF needs to do a replace) the configured destroy_cmd_entrypoint and destroy_cmd_body should be invoked, similar to what happens on create, where the create_cmd_entrypoint and create_cmd_body are clearly invoked.

Observed behavior

Creates are doing as expected, calling the configured entrypoint, but destroys are not. The .tfstate data is indeed created and destroyed as expected, but the custom entrypoints are never getting invoked.

Terraform Configuration

terraform {
  required_version = ">= 1.0.0"

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "3.90.0"
    }
  }
}

provider "google" {
  region      = "us-central1"
  project     = "my-xxx"
  credentials = "my-xxx-account.json"
}

# comment out the module below after "create" to get TF to "destroy"
module "my_xxx_tester" {
  source  = "terraform-google-modules/gcloud/google"
  version = "3.1.0"

  create_cmd_endpoint = "gcloud"
  create_cmd_body        = "version"
  destroy_cmd_body      = "gcloud"
  destroy_cmd_body       = "version"
}

Terraform Version

Terraform v1.1.5
on darwin_amd64

Debug Output

https://gist.github.com/crandall-chow-bl/b5a427c276f6c2c6be0d402304affe53

Additional information

Steps to Reproduce

  1. terraform apply with the TF file above to "create"
  2. Comment out the module in the TF file
  3. `terraform apply" with the TF file above to "destroy"
  4. Note that the destroy entrypoint/body do not get invoked
@crandall-chow-bl crandall-chow-bl added the bug Something isn't working label Feb 16, 2022
@morgante
Copy link
Contributor

What happens if you run terraform destroy instead of commenting the module out?

@crandall-chow-bl
Copy link
Author

crandall-chow-bl commented Feb 16, 2022

Will try that and reply but that's certainly not what I want to do. Commenting it out is just the test to show how the "destroy" can be called.

The actual use case is to pass a release number in the create_cmd_body. When I want to deploy a new version, I update the module stanza with the new version number. Calling terraform apply will see the change to the module, and have it do a "replace" (invoking my previous destroy_cmd_entrypoint and destroy_cmd_body saved in the .tfstate, then invoking the new create_cmd_entrypoint and body).

Also, notice in the debug output, some "destroy" is indeed being triggered, but my configured entrypoint/body are not called.

@morgante
Copy link
Contributor

Will try that and reply but that's certainly not what I want to do. Commenting it out is just the test to show how the "destroy" can be called.

Yeah, I'm mostly trying to figure out why it wouldn't be invoked in your environment.

@crandall-chow-bl
Copy link
Author

crandall-chow-bl commented Feb 21, 2022

I attempted the terraform destroy and sure enough, doing THAT does indeed invoke the entrypoint and body (see gist below). So it's just the destroy on a normal apply path (e.g. delete the resource, or modify the resource causing a delete/create replace) where the endpoint/body aren't being invoked.

https://gist.github.com/crandall-chow-bl/b5a427c276f6c2c6be0d402304affe53#file-destroy-txt

This is on macOS 12.2.1 in case that matters.

@morgante
Copy link
Contributor

morgante commented Mar 8, 2022

Unfortunately it looks like this is a Terraform Core issue: hashicorp/terraform#13549

@morgante morgante added upstream Work required on Terraform core or provider P4 low priority issues labels Mar 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label May 7, 2022
@bharathkkb bharathkkb added triaged Scoped and ready for work and removed Stale labels May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P4 low priority issues triaged Scoped and ready for work upstream Work required on Terraform core or provider
Projects
None yet
Development

No branches or pull requests

3 participants