I know there were similar issues raised before BUT we do have the required provider set in the env folder in each environment and still getting the warning message in all of our modules - we are trying to upgrade from 1.3.2 to 1.9.5 and cleaning up warnings and deprecations in the code
│ Warning: Reference to undefined provider
│
│ on module-us-east-1.tf line 13, in module "policy_us-east-1":
│ 13: aws = aws.us-east-1
│
│ There is no explicit declaration for local provider name "aws" in module.policy_us-east-1, so Terraform is assuming you mean to pass a configuration for "hashicorp/aws".
│
│ If you also control the child module, add a required_providers entry named "aws" with the source address "hashicorp/aws".
│
│ (and 166 more similar warnings elsewhere)
Files structure:
TF
|env
||development
providers.tf
main.tf
variables.tf
module-us-east-1.tf
module-eu-west-2.tf
||preproduction
providers.tf
main.tf
variables.tf
module-us-west-2.tf
|modules
||testing
test.tf
variables.tf
outputs.tf
providers.tf
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
assume_role {
role_arn = xxxx
session_name = xxxx
}
}
provider "aws" {
alias = "eu-west-2"
region = "eu-west-2"
assume_role {
role_arn = xxxxxx
session_name = xxxxxxx
}
}
}
}
main.tf
terraform {
required_version = "=1.3.2"
backend "s3" {
bucket =
region = "us-east-1"
}
required_providers {
aws = {
source = "hashicorp/aws"
version = xxxxx
}
tls = {
source = "hashicorp/tls"
version = xxxxx
}
}
}
module-us-east-1.tf
module "testing" {
source = "../../modules/testing"
name = "Testing"
instance_type = "c5.2xlarge"
cidr_block = "0.0.0.0"
security_group_id = "sg-12345678"
policy_arn = "arn:aws:iam::12345678:policy/some_policy"
providers = {
aws = aws.us-east-1
}
}
if I will put the required provides in module-us-east-1.tf like everyone is suggesting (deleting it from main.tf), I am getting this error
│ Error: Duplicate required providers configuration
│
│ on modules_us-east-1.tf line 6, in terraform:
│ 6: required_providers {
│
│ A module may have only one required providers configuration. The required providers were previously configured at main.tf:9,3-21.
This warning is also in the single region modules and if I do configuration_aliases