Home

Awesome

<p align="center"> <img alt="terradozer" src="https://github.com/jckuester/terradozer/blob/master/img/logo.png" height="180" /> <h3 align="center">terradozer</h3> <p align="center">Terraform destroy using the state only - no *.tf files needed</p> </p>

Release Software License Travis Codecov branch Go Doc

Terradozer takes a Terraform state file as input and destroys all resources it finds in it - without needing any *.tf files. This works currently only for resources of the Terraform AWS Provider. If you need support for any other provider, let me know, and I will try to help.

Happy (terra)dozing!

Example

Features

Installation

It's recommended to install a specific version of terradozer available on the releases page.

Here is the recommended way to install terradozer v0.1.2:

# install it into ./bin/
curl -sSfL https://raw.githubusercontent.com/jckuester/terradozer/master/install.sh | sh -s v0.1.2

Usage

To delete all resources in a Terraform state file:

terradozer [flags] <path/to/terraform.tfstate>

To see all options, run terradozer --help. Provide credentials for the AWS account you want to destroy resources in via the usual environment variables, e.g., AWS_PROFILE=<myaccount> and AWS_DEFAULT_REGION=<myregion>.

The region information is needed as it is not stored as part of the state. Having multiple providers with different regions in one state file is not yet supported.

How it works

Terradozer first scans a given Terraform state file (read-only) to find all resources (excluding data sources), then downloads the necessary Terraform Provider Plugins to call the destroy function for each resource on the respective CRUD API via GRPC (e.g., calling the Terraform AWS Provider to destroy a aws_instance resource).

Tests

This section is only relevant if you want to contribute to Terradozer and therefore run the tests. Terradozer has acceptance tests, integration tests checking against changes of behaviour in the Terraform Provider API, and of course unit tests.

Run unit tests

make test

Run acceptance and integration tests

AWS_PROFILE=<myaccount> AWS_DEFAULT_REGION=<myregion> make test-all