kjbradley
kjbradley

Reputation: 335

Terraform-AWS 0.10.3: Unable to destroy cluster with instance that has deleted AMI

I'm uncertain of how terraform is supposed to behave in this scenario:

  1. We bring up a cluster of instances, one of which has an ami that was deleted while the cluster is running.
  2. We try to destroy this cluster and terraform fails in the refresh phase because the query trying to find the ami fails.

In my mind, the ami shouldn't be needed any longer in order to destroy a cluster - the instance already exists, and so terraform should destroy the cluster.

Perhaps there is a work-around here? Or should I file an issue?

Upvotes: 0

Views: 921

Answers (1)

Martin Atkins
Martin Atkins

Reputation: 74694

By default Terraform refreshes all resources before taking any actions to ensure that it is working from the most up-to-date record of the state of the world.

In situations where this is not suitable -- such as the one you've described here -- this behavior can be disabled by passing the option -refresh=false to the terraform destroy command. In this case, Terraform will use the values already saved in the state from a previous run, skipping the "refresh" step that would normally update them.

Upvotes: 4

Related Questions