Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Terraform destroy without configuration files

License

NotificationsYou must be signed in to change notification settings

jckuester/terradozer

Repository files navigation

terradozer

terradozer

Terraform destroy using the state only - no *.tf files needed


ReleaseSoftware LicenseTravisCodecov branchGo Doc

Terradozer takes a Terraform state file as input and destroys all resources it finds in it - without needing any *.tffiles. 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

  • Nothing will be deleted without your confirmation. Terradozer always lists all resources first and then waits foryour approval
  • Using the-force flag (dangerous!), terradozer can run in an automated fashion without human interaction and approval,for example, as part of your CI pipeline
  • Planned, if you want me to implement this,please upvote:Allow terradozer pointing directly to a state file stored in S3, i.e.,terradozer s3://path/to/terraform.tfstate
  • Planned, if you want me to implement this,please upvote:A-recursive flag to delete resources of all states found under a given directory, i.e.,terradozer -recursive s3://bucket-with-states/. This is especially helpful ifyou orchestrate Terraform modules withTerragrunt and store all statesunder the same directory or in the same S3 bucket. This way, a complete Terragrunt project could be cleaned up in anautomated fashion.

Installation

It's recommended to install a specific version of terradozer available on thereleases 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, runterradozer --help. Provide credentials for the AWS account you want to destroy resources invia the usualenvironment variables, e.g.,AWS_PROFILE=<myaccount> andAWS_DEFAULT_REGION=<myregion>.

The region information is needed as it is not stored as part of the state. Having multiple providers with differentregions 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 respectiveCRUD API via GRPC (e.g., calling the Terraform AWS Provider to destroy aaws_instance resource).

Tests

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

Run unit tests

make test

Run acceptance and integration tests

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

[8]ページ先頭

©2009-2025 Movatter.jp