Loading...
Loading...
### Terraform Version ```shell `Terraform v1.11.3` ``` ### Terraform Configuration Files So I had this configuration at the main level: ```terraform provider "aws" { alias = "cdn_provider" region = "us-east-1" default_tags { tags = { Project = local.project_name } } } module "private-cloud" { source = "./modules/private-cloud" ... providers = { aws.cdn_provider = aws.cdn_provider aws.aws_no_defaults = aws.aws_no_defaults } } ``` And inside module: ``` terraform { required_providers { acme = { source = "vancluever/acme" version = "~> 2.26" } aws = { source = "hashicorp/aws" configuration_aliases = [ aws.cdn_provider, aws.aws_no_defaults, ] } } } provider "acme" { server_url = "https://acme-v02.api.letsencrypt.org/directory" } ``` From the submodule the resources were removed and created another submodule at toop level. Provider was renamed: cdn_provider -> ssl_provider. I am aware of this problem: ``` │ Error: Provider configuration not present │ │ To work with module.private-cloud.aws_acm_certificate_validation.acm-ssl-cdn (orphan) its original provider │ configuration at provider["registry.terraform.io/hashicorp/aws"].cdn_provider is required, but it has been │ removed. This occurs when a provider configuration is removed while objects created by that provider still exist │ in the state. Re-add the provider configuration to destroy │ module.private-cloud.aws_acm_certificate_validation.acm-ssl-cdn (orphan), after which you can remove the provider │ configuration again. ``` Thus `terraform.required_providers` block was not removed from submodule. Because provider was renamed at top level I changed how it is passed to submodule: ```tf providers = { aws.cdn_provider = aws.ssl_provider aws.aws_no_defaults = aws.aws_no_defaults } ``` But this does not work, submodule still looking for `cdn_provider` to exists. The next is very surprising. If I still pass `ssl_provider` into submodule, but just define `cnd_provider` at top level **without passing it to submodule** the submodule "magically" sees `cdn_provider` though `aws.ssl_provider` is passed. ```tf provider "aws" { alias = "ssl_provider" region = "us-east-1" default_tags { tags = { Project = local.project_name } } } provider "aws" { alias = "cdn_provider" region = "us-east-1" default_tags { tags = { Project = local.project_name } } } ``` And this `cdn_provider` works even if I change its `region` to the wrong one. ### Debug Output I can send it privately. ### Expected Behavior Terraform should pass correct provider into submodule This config should pass `ssl_provider` into submodule as `cdn_provider` even if another provider at top level with `cdn_provider` name still exists. ```tf aws.cdn_provider = aws.ssl_provider aws.aws_no_defaults = aws.aws_no_defaults ``` Submodule should not see the names of provider at top level. Submodule should see only the names defined at `providers` block. ### Actual Behavior TF passes the previous provider into submodule even if the different provider was passed. ### Steps to Reproduce 1. create configuration with X provider 2. Pass X provider into submodule 3. create another Y provider 4. pass Y as X into submodule: `providers { aws.X = aws.Y }` 5. terraform plan/apply. You will get error here 6. define X provider at the top level 7. terraform plan/apply. Even if Y passed to submodule as X, the submodule "magically" sees `X` provider from the top level. ### Additional Context _No response_ ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.