Skip to content

configuration_aliases in child module terraform validate fails: Provider configuration not present #28490

Open
@RobertKeyser

Description

@RobertKeyser

Terraform Version

v0.15.0

Terraform Configuration Files

terraform {
  required_version = ">= 0.15.0"
  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = "~> 3.0"
      configuration_aliases = [ aws.replica ]
    }
  }
}
...
resource "aws_kms_key" "replica_bucket_key" {
  provider = aws.replica
  ...
}
...

Expected Behavior

Expected to see valid configuration errors for any resource referencing the alias provider.

Actual Behavior

Errors on all resources using the alias provider. What I find interesting is that it says that the resources are in state, but there's no state, per terraform show.

PS C:\REDACTED\s3> terraform version
Terraform v0.15.0
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v3.37.0
PS C:\REDACTED\s3> terraform show       
No state.
PS C:\REDACTED\s3> terraform validate
╷
│ Error: Provider configuration not present
│
│ To work with aws_kms_alias.replica_bucket_key_alias its original provider configuration at provider["registry.terraform.io/hashicorp/aws"].replica 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 aws_kms_alias.replica_bucket_key_alias, after which you can remove the provider configuration again.

Steps to Reproduce

  1. terraform init
  2. terraform validate

Additional Context

This is a child module that I've migrated from v0.14.4. It was originally using proxy provider configuration. I tried running a validate on directly it after adding in the configuration_aliases setting. I'm able to run an apply on a main.tf that references it, but just not able to validate the child module.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfigpending projectissue is confirmed but will require a significant project to fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions