Can we destroy/remove all resources deployed via module

Hi there,

I’m posting this question to know if I can destroy/remove all the resources created by a module. Here is the catch, I am calling that module on a counter, so multiple resources are created.

module1 = 10 resources
module2 = 10 resources
module3 = 10 resources

Now I want to delete module2, is there a simple way to delete all the 10 resources created under module2?

Another similar question is can we delete/remove resources with counter?


can I delete resource for something similar to:
# this doesn't work in terraform
terraform destroy -target aws_instance.fruit[1]

I was going through these links:


Hi @Let-itGo,

The usual way to destroy something in Terraform is to remove it from your configuration and run terraform apply.

Terraform is a “desired state” system, and so it will notice that the objects it previously created are no longer in the configuration (which describes the “desired state”) and so propose to delete them to make the remote system match your configuration change.