> For the complete documentation index, see [llms.txt](https://notes.nomanaziz.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.nomanaziz.me/devops/infrastructure-as-a-code-iac/terraform/3.-delete-resources.md).

# 3. Delete Resources

* If we want to destroy the instance that we created, we can use the command `terraform destroy`
* Keep in mind that by default it destroys all the resources specified in the config file
* To delete a single resource, specific flags must be passed to the command
* In the previous example, if we want to delete the ec2 instance without using `terraform destroy` command, then, we will comment out the ec2 resource and re apply the config. Terraform will figure it out and delete the ec2 instance for us

```hcl
#####################
# Modifying EC2 Instance Tag
#####################
#resource "aws_instance" "my-first-server" {
#    ami = "ami-052efd3df9dad4825"
#    instance_type = "t2.micro"
#
#    tags = {
#        Name = "ubuntu"
#    }
#}
```
