Terraform: taint all resources from one module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
terraform state list|grep <MODULE_FULL_PATH> | xargs terraform taint ; terraform plan -out plan; terraform apply plan -auto-approve
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice, just want I was looking for. Thanks