Wednesday, January 16, 2019

How to destroy a specific resource using Terraform - Destroy specific resource using Terraform

If you would like to destroy all the resources you had created using Terraform, all you have to do is perform the below command:
 
terraform destroy
 
The above command will destroy all the resources. 
 
But let's say you would like to destroy only a specific resource you have created using Terraform. You can do it by passing a an argument in terraform destroy command. if you would like to delete EC2 instance, you can mention like below:

Destroy specific resources
terraform destroy -target aws_instance.myInstanceName

if you would like to delete a security group, you can mention like below:
terraform destroy -target aws_security_group.security_group_name
 
Please watch in YouTube on how to do the above steps:


No comments:

Post a Comment