Module does not declare a provider named aws

I am using terraform version 1.1.0 and AWS provider version. Below the config file I used to declare required providers block.

terraform {
required_providers {
aws = {
version = “>= 3.68.0”
source = “hashicorp/aws”
configuration_aliases = [aws.stage, aws.research]
}
}
}

provider “aws” {
alias = “stage”
region = “us-east-1”
}

We are using terraform modules and for each environment we are declaring the terraform
provider as below and use the provider in the module as below

module “route53_dns_forwarder” {
source = “…/…/TerraformModules/route53_dns_forwarder”
providers = {
aws = aws.stage
}
}
When I try to run the terraform validate I am getting the below warning message.

Module module.stage does not declare a provider named aws. If you wish to specify a provider configuration for the module, add an entry for aws in the required_providers block within the module.

The work arounds we found on google did not work. Any ideas or suggestions on this.

you shoudl add a configuration_aliases in the child module, e.g.

terraform {
  required_version = ">= 1.0.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.45.0"
      configuration_aliases = [ aws.org ]
    }
  }
}

Hey @chnaresh26 :wave: Like @vikasreddy1697 mentioned above, the configuration_aliases declaration will need to be within the child module. I recently answered a similar question in an issue on the AWS Provider GitHub repository that you may find helpful:

@vikasreddy1697 @justinretzolk Thanks much for your help. We are able to resolve the issue.