# Issues Destroying EC2 Instances in Terraform

**URL:** <https://discuss.hashicorp.com/t/issues-destroying-ec2-instances-in-terraform/11364>\
**Category:** Terraform\
**Created:** [July 12, 2020, 5:39pm UTC](https://discuss.hashicorp.com/t/issues-destroying-ec2-instances-in-terraform/11364 "2020-07-12T17:39:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![verbosesecurity](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/verbosesecurity/32/9309_2.png) [@verbosesecurity](https://discuss.hashicorp.com/u/verbosesecurity)\
**Post date:** [July 12, 2020, 5:39pm UTC](https://discuss.hashicorp.com/t/issues-destroying-ec2-instances-in-terraform/11364/1 "2020-07-12T17:39:12Z")

</div>

I’ve attempted to research the following in google but surprisingly I haven’t found a straight forward answer:

1. How would I delete specific EC2 instances by passing the instance id as it appears in AWS? For example, when I used terraform to create my instances, AWS automatically created ids for them such as “i-0XXXXXXXXXXXXXXXX”. Is there a command such as "terraform destroy -id=“i-0XXXXXXXXXXXXXXXX”.

2. How would I delete multiple EC2 instances by passing the name I specified in the main.tf file? For example, I created 2 resource blocks that say “resource ‘aws\_instance’ ‘Udacity\_foo’”. How can I pass ‘Udacity\_foo’ into a command such as “terraform destroy -name=‘Udacity\_foo’”, which would delete all instances matching Udacity\_foo as terraform recognizes it.

3. Are tasks 1 and 2 above possible by using a terraform configuration file? For example, I could write “instances\_to\_delete.tf” and type a command such as "terraform destroy -config=‘instances\_to\_delete.tf’.
