-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Open
Labels
Description
Terraform Version
$ terraform version
Terraform v1.14.3
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.26.0Terraform Configuration Files
./main.tf
terraform {
required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
}
}
}
provider "postgresql" {
alias = "source"
host = "127.0.0.1"
port = 5432
username = "postgres"
password = "postgres"
}
provider "postgresql" {
alias = "destination"
host = "127.0.0.1"
port = 5432
username = "postgres"
password = "postgres"
}
module "replication" {
source = "./replication"
providers = {
postgresql.source = postgresql.source
postgresql.destination = postgresql.destination
}
}
# module "new" {
# source = "./new"
# }./replication/main.tf
terraform {
required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
configuration_aliases = [
postgresql.source,
postgresql.destination,
]
}
}
}./new
(Empty directory)
Debug Output
$ TF_LOG=DEBUG terraform plan
2026-01-15T15:45:29.226+0100 [INFO] Terraform version: 1.14.3
2026-01-15T15:45:29.227+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.94.0
2026-01-15T15:45:29.227+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.24.0
2026-01-15T15:45:29.227+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2026-01-15T15:45:29.227+0100 [DEBUG] using github.com/zclconf/go-cty v1.16.3
2026-01-15T15:45:29.227+0100 [INFO] Go runtime version: go1.25.5
2026-01-15T15:45:29.227+0100 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/3.0.0/versions/1.14.3/terraform", "plan"}
2026-01-15T15:45:29.227+0100 [DEBUG] Attempting to open CLI config file: /Users/magul/.terraformrc
2026-01-15T15:45:29.227+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2026-01-15T15:45:29.227+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2026-01-15T15:45:29.227+0100 [DEBUG] ignoring non-existing provider search directory /Users/magul/.terraform.d/plugins
2026-01-15T15:45:29.227+0100 [DEBUG] ignoring non-existing provider search directory /Users/magul/Library/Application Support/io.terraform/plugins
2026-01-15T15:45:29.227+0100 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2026-01-15T15:45:29.227+0100 [INFO] CLI command args: []string{"plan"}
2026-01-15T15:45:29.241+0100 [DEBUG] checking for provisioner in "."
2026-01-15T15:45:29.241+0100 [DEBUG] checking for provisioner in "/usr/local/Cellar/tfenv/3.0.0/versions/1.14.3"
2026-01-15T15:45:29.242+0100 [INFO] backend/local: starting Plan operation
╷
│ Error: Provider type mismatch
│
│ on main.tf line 4, in module "replication":
│ 4: postgresql.source = postgresql.source
│
│ The local name "postgresql.source" in the root module represents provider "hashicorp/postgresql", but "postgresql.source" in
│ module.replication represents "cyrilgdn/postgresql".
│
│ Each provider has its own distinct configuration schema and provider types, so this module's "postgresql.source" can be assigned
│ only a configuration for cyrilgdn/postgresql, which is not required by module.replication.
╵
╷
│ Error: Provider type mismatch
│
│ on main.tf line 5, in module "replication":
│ 5: postgresql.destination = postgresql.destination
│
│ The local name "postgresql.destination" in the root module represents provider "hashicorp/postgresql", but "postgresql.destination"
│ in module.replication represents "cyrilgdn/postgresql".
│
│ Each provider has its own distinct configuration schema and provider types, so this module's "postgresql.destination" can be
│ assigned only a configuration for cyrilgdn/postgresql, which is not required by module.replication.
╵
╷
│ Error: Module not installed
│
│ on main.tf line 9:
│ 9: module "new" {
│
│ This module is not yet installed. Run "terraform init" to install all modules required by this configuration.
╵
Expected Behavior
Terraform should properly recognize non-HashiCorp providers, even if they are passed as aliases to sub-modules.
Actual Behavior
When running plan (with not-yet-initialized module) Terraform complains about
│ The local name "postgresql.destination" in the root module represents provider "hashicorp/postgresql", but "postgresql.destination"
│ in module.replication represents "cyrilgdn/postgresql".
│
│ Each provider has its own distinct configuration schema and provider types, so this module's "postgresql.destination" can be
│ assigned only a configuration for cyrilgdn/postgresql, which is not required by module.replication.
Steps to Reproduce
- run
terraform init - run
terraform plan - uncomment
module "new" {
source = "./new"
}- run
terraform plan - observe errors
Additional Context
AFAIK this is limited only to providers passed to aliases (default providers are not complained about).
After running terraform init (which succeed) terraform plan do not complain anymore.
References
#33784 - this looks similar, but is about terraform init, where in my situation terraform init make problem go away.
Generative AI / LLM assisted development?
No response