Usage example fails with 'The argument "region" is required, but was not set.'
Describe the Bug
I tried the usage example with the module from the README, i.e.
module "terraform_state_backend" {
source = "git::https://github.com/cloudposse/terraform-aws-tfstate-backend.git?ref=tags/0.14.0"
namespace = "eg"
stage = "test"
name = "terraform"
attributes = ["state"]
region = "us-east-1"
}
in a terraform.tf file and nothing else.
I then ran terraform init, which worked as expected:
Initializing modules...
Downloading git::https://github.com/cloudposse/terraform-aws-tfstate-backend.git?ref=tags/0.14.0 for terraform_state_backend...
- terraform_state_backend in .terraform/modules/terraform_state_backend
Downloading git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.13.0 for terraform_state_backend.base_label...
- terraform_state_backend.base_label in .terraform/modules/terraform_state_backend.base_label
Downloading git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.13.0 for terraform_state_backend.dynamodb_table_label...
- terraform_state_backend.dynamodb_table_label in .terraform/modules/terraform_state_backend.dynamodb_table_label
Downloading git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.13.0 for terraform_state_backend.s3_bucket_label...
- terraform_state_backend.s3_bucket_label in .terraform/modules/terraform_state_backend.s3_bucket_label
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "local" (hashicorp/local) 1.4.0...
- Downloading plugin for provider "null" (hashicorp/null) 2.1.2...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.52.0...
- Downloading plugin for provider "template" (hashicorp/template) 2.1.2...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform apply however fails in a rather surprising way:
Error: Missing required argument
The argument "region" is required, but was not set.
Obviously the region is set, just as in the example. Using a different region doesn't change the result.
Expected Behavior
S3 bucket and Dynamo table are created and ready for use.
Steps to Reproduce
Follow the README usage example until step 3.
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas:
- OS: macOS
- Version: 10.15.3
Additional Context
I saw that some other issues also had problems getting this to work, but none of the hacks described there (adding a aws = "aws" provider) helped.
we are having the same issue. any update on this issue?
adding
provider "aws" {
region = "us-east-1"
}
to mian.tf file where you are calling the module solved my issue
Conversely, the AWS_REGION environment variable can be set. I'm not sure of the proper way to configure this in terraform 0.13 at this time.
EDIT:
I guess the provider block is still staying around per examples in the docs. I was under the mistaken impression that this block was going away.
Closing as "invalid" because the provider block must be set in root modules, per the Terraform documentation.