Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interrupted terraform apply, now cannot destroy or apply

Tags:

terraform

So I have an application that runs terraform apply in a directory, then can also run terraform destroy. I was testing the application, and I accidentally interrupted the processes while running apply

Now it seems to be stuck with a partially created instance, where it recognizes the name of my instance I was creating/destroying and when I try to apply it says that an instance of that name already exists. But then destroy says there is nothing to destroy. So I can't do either. Is there anyway to unsnarl this?

like image 394
bock.steve Avatar asked May 02 '18 04:05

bock.steve


2 Answers

you can run the below to view all current resources still live from the project directory:

$ terraform state list

to destroy each resource run the below on each individual resource:

$ terraform destroy --target=resource.name

could write a script to loop through the 'terraform state list' output if there is a lot.

like image 138
tkjef Avatar answered Sep 22 '22 15:09

tkjef


I'm afraid that the only option is by doing:

  1. execute terraform state rm RESOURCE example: terraform state rm aws_ebs_volume.volume.

  2. Manually remove the resource from your cloud provider.

like image 30
ThomasVdBerge Avatar answered Sep 23 '22 15:09

ThomasVdBerge