Terraform-provider-aws: Terraform cannot destroy an AWS cluster if the ami was deleted

Created on 6 Sep 2017  ·  5Comments  ·  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @KevinCSI as hashicorp/terraform#16024. It was migrated here as a result of the provider split. The original body of the issue is below._


Hi there,

I was trying to destroy a cluster that contained an instance based off of a (now) deleted ami, but Terraform is unable to pass the refresh phase. It failed due to not being able to locate the ami in question (query failed, see below for details in Steps to Reproduce).

Terraform Version

Terraform v0.10.3

Expected Behavior

Cluster should destroy successfully

Actual Behavior

What actually happened?
terraform failed during the refresh phase

Steps to Reproduce

Please list the full steps required to reproduce the issue, for example:

  1. bring up a cluster with ami [X]
  2. delete ami [x]
  3. destroy the cluster that contains instance[y] that was based off ami[x]
  4. you will see the error: Your query returned no results. Please change your search criteria and try again
bug servicec2

Most helpful comment

Yes, terraform destroy -refresh=false destroyed the infra.

All 5 comments

I would suggest disabling the -refresh phase using the appropriate flag
https://www.terraform.io/docs/commands/plan.html#refresh-true

Adding -refresh=true to terraform plan command didn't help. I'm using Terraform v0.11.11 from the Docker container.

$ terraform plan -refresh=true
X: Refreshing state...
Y: Refreshing state...
...
Releasing state lock. This may take a few moments...

2019/03/19 02:29:24 [DEBUG] plugin: waiting for all plugin processes to complete...
Error: Error refreshing state: 4 error(s) occurred:

* data.aws_ami.bastion: 1 error(s) occurred:

* data.aws_ami.bastion: data.aws_ami.bastion: Your query returned no results. Please change your search criteria and try again.
* data.aws_ami.base-linux: 1 error(s) occurred:

* data.aws_ami.base-linux: data.aws_ami.base-linux: Your query returned no results. Please change your search criteria and try again.
* data.aws_ami.jenkins-master: 1 error(s) occurred:

* data.aws_ami.jenkins-master: data.aws_ami.jenkins-master: Your query returned no results. Please change your search criteria and try again.
* data.aws_ami.jenkins-docker-slave: 1 error(s) occurred:

* data.aws_ami.jenkins-docker-slave: data.aws_ami.jenkins-docker-slave: Your query returned no results. Please change your search criteria and try again.

Yes, terraform destroy -refresh=false destroyed the infra.

This appears to be resolved, so closing this issue. 👍

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings