Skip to content

Instantly share code, notes, and snippets.

@justinclayton
Created January 19, 2016 18:48
Show Gist options
  • Save justinclayton/01f349f66e908a243709 to your computer and use it in GitHub Desktop.
Save justinclayton/01f349f66e908a243709 to your computer and use it in GitHub Desktop.
Terraform: taint all resources from one module
#!/bin/bash
module=$1
for resource in `terraform show -module-depth=1 | grep module.${module} | tr -d ':' | sed -e 's/module.${module}.//'`; do
terraform taint -module ${module} ${resource}
done
@dmitry-mightydevops
Copy link

For those who needs a makefile recipe:

taint_module: ## Recreate entire module `MODULE="module.cassandra-cluster" make taint_module`
	for resource in `terraform state list | grep module.${MODULE}`; do terraform taint $$resource; done

@devtech0101
Copy link

terraform state list|grep <MODULE_FULL_PATH> | xargs terraform taint ; terraform plan -out plan; terraform apply plan -auto-approve

@a03173a
Copy link

a03173a commented Feb 23, 2024

atlantis plan -p infrastructure-stage

@justinclayton
Copy link
Author

rm -f terraform.tfstate*

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