terraform: AWS provider - missing region

1 min read | by Jordi Prats

We might face the following error when trying to apply terraform:

$ terraform plan
Acquiring state lock. This may take a few moments...

Error: Missing required argument

The argument "region" is required, but was not set.

Releasing state lock. This may take a few moments...

Even though we might have set the default region on our AWS profile:

$ cat ~/.aws/config 
[profile independencia]
region=eu-west-1
(...)

Terraform is not picking it up, instead we can set the AWS_DEFAULT_REGION environment variable and apply terraform:

$ AWS_DEFAULT_REGION=es-west-1 terraform plan
(...)

But, instead, what we should be doing is to properly set the default region when initializing the AWS provider:

provider "aws" {
  region = "eu-west-1"
}

Posted on 16/02/2021

Categories