terraform-zap
Script wrapper to perform finer terraform destroy. This means that terraform
must still be installed and residing within PATH
environment variable.
Currently if any of the .tf
files contain prevent_destroy = true
for any of
the resources, terraform destroy
will fail and there is no flag to force
terraform
to skip all resources. This script wrapper helps to alleviate the
issue by parsing .tfzignore
file in the current working directory, where the
.tf
files are residing in.
Previously the ignore file was named .tfignore
up to v0.1.1
, however this
clashes with the Microsoft Team Foundation ignore file naming, so this has been
changed to .tfzignore
.
.tfzignore
formattoml
exact = [
"important_database.xxx",
"important_role.xxx",
]
If there are resources that exactly match the names above, these resources are
automatically skipped, solving the problem of having to type complicated
commands in order to skip the above resources to possibly resolve the
prevent_destroy = true
issue, with just a single command.
Use https://www.rustup.rs/ and get the commands cargo
and
rustc
.
Run cargo install terraform-zap
for the installation. This will automatically
fetch terraform-zap
CLI application from crates.io
and install into your Cargo installation binary directory.
With .tfzignore
file in place, simply run terraform-zap
. You should see
mainly terraform destroy
logs in place, but the ignored resources should now
no longer appear during the confirmation.
If previously there were resources
with prevent_destroy = true
set, if these resources are correctly ignored,
the confirmation prompt should appear properly.
For more CLI argument details, type terraform-zap -h
.
Run cargo build --all --release
. This builds all the associated libraries
and the executable. The executable will be built in
target/release/terraform-zap
.