Home > Software design >  How to supply variables to terraform destroy?
How to supply variables to terraform destroy?

Time:10-22

I'm trying to destroy some aws resources created using Terraform. I have my region set as a variable in my provider resource like this

provider "aws" {
  region = var.aws_region
}

I have the variable set empty by default because I only supply them using a json file during terraform plan/apply.

Now when I run terraform destroy, it says Error: Invalid AWS Region:.

I checked if we can supply variables during destroy but sadly we cannot. I also checked if we can destroy using the applied plan, we cannot do this either. How do I fix this?

CodePudding user response:

This is a know issue with Terraform 0.15.0 that is fixed on the version 0.15.1, you can update your terraform for this new version and try again. To read more about this issue, take a look here.

As a workaround you can try to set AWS_REGION env before running the terraform destroy

AWS_REGION=us-west-2 terraform destroy

or ending adding the region manually:

provider "aws" {
   region = "us-east-1"
}
  • Related