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 does not handle 404 on Google Compute Instance #3990

Closed
clstokes opened this issue Nov 20, 2015 · 3 comments
Closed

Terraform destroy does not handle 404 on Google Compute Instance #3990

clstokes opened this issue Nov 20, 2015 · 3 comments

Comments

@clstokes
Copy link
Contributor

If I create a Google Compute Instance with Terraform, then remove the instance via the Google Cloud console, a terraform destroy fails with a no longer exists error (likely a 404) and won't continue. Other Terraform providers seem to handle this case by handling the 404 as a successful destroy and continuing on.

Tested with Terraform v0.6.6.

Terraform config:

resource "google_compute_instance" "main" {
  name         = "main"
  machine_type = "n1-standard-1"
  zone         = "us-central1-f"

  disk {
    image = "ubuntu-1404-trusty-v20151113"
  }

  network_interface {
    network = "default"
    access_config {
      // Ephemeral IP
    }
  }
}

Abridged Terraform output...

$ terraform apply

...

google_compute_instance.main: Creating...
  can_ip_forward:                             "" => "0"
  disk.#:                                     "" => "1"
  disk.0.auto_delete:                         "" => "1"
  disk.0.image:                               "" => "ubuntu-1404-trusty-v20151113"
  machine_type:                               "" => "n1-standard-1"
  metadata_fingerprint:                       "" => "<computed>"
  name:                                       "" => "main"
  network_interface.#:                        "" => "1"
  network_interface.0.access_config.#:        "" => "1"
  network_interface.0.access_config.0.nat_ip: "" => "<computed>"
  network_interface.0.address:                "" => "<computed>"
  network_interface.0.name:                   "" => "<computed>"
  network_interface.0.network:                "" => "default"
  self_link:                                  "" => "<computed>"
  tags_fingerprint:                           "" => "<computed>"
  zone:                                       "" => "us-central1-f"
google_compute_instance.main: Creation complete

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

...

$ 
$ # Instance removed via Google Cloud console
$ 
$ terraform destroy -force

...

google_compute_instance.main: Refreshing state... (ID: main)
Error refreshing state: 1 error(s) occurred:

* google_compute_instance.main: Resource hashicorp-clstokes no longer exists
$
@lwander
Copy link
Contributor

lwander commented Nov 23, 2015

This has already been brought up in #3742, and is being addressed in #3913. However, @apparentlymart made the case that the typical behavior is to allow terraform show to resolve this by calling Read(..) on the deleted resources, marking them as no longer existing. What do you think, @clstokes?

@clstokes
Copy link
Contributor Author

I'm definitely good with @apparentlymart's suggestion. I'll close this in favor of #3742. Thanks @lwander!

@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants