Post

Destroy Terraform project with -backend-config

How to destroy a Terraform project using a custom backend-config path for the state file.

To destroy a Terraform-managed infrastructure when the state file is stored at a custom local path, first set your AWS credentials as environment variables, then run terraform init with the -backend-config flag pointing to the state file location, and finally run terraform destroy.

1
2
3
4
5
6
7
export AWS_SECRET_ACCESS_KEY="..."
export AWS_ACCESS_KEY_ID="..."
export AWS_DEFAULT_REGION="us-west-2"
export TF_VAR_project_name=hruska
cd terraform/k3s
terraform init -backend-config="path=/home/jantoth/Documents/sbx/ml/data/hruska/terraform.tfstate"
terraform destroy
This post is licensed under CC BY 4.0 by the author.