Skip to content

Instantly share code, notes, and snippets.

@denzhel
Last active August 2, 2021 17:59
Show Gist options
  • Select an option

  • Save denzhel/d8a1476fb2464a6d377bcea6154947d3 to your computer and use it in GitHub Desktop.

Select an option

Save denzhel/d8a1476fb2464a6d377bcea6154947d3 to your computer and use it in GitHub Desktop.
Apply or Destroy Terraform resources

If you want to destroy something from your state that has a lot of resources with a common name you can use the following:

terraform apply $(for i in $(tf state list | grep <Name>); do echo -n "-target=$i " ; done) 

e.g I use it to destroy a datastore that has many resources such as EC2, Route53 records, EBS and etc ..

#terraform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment