Need help understanding "Provider type mismatch" error

I have made a change to a terraform module to use a different version of a module source:

module "resources" {
  providers = {
    snowflake.sys = snowflake.sys
    snowflake.sec = snowflake.sec
  }
-  source = "git::https://github.com/org/repo//terraform/modules/foo?ref=bar"
+  source = "git::https://github.com/org/repo//terraform/modules/foo?ref=baz"
   ...
   ...
}

When running terraform plan I got error

  ╷
  │ Error: Provider type mismatch
  │ 
  │   on resources.tf line 41, in module "resources":
  │   41:     snowflake.sys = snowflake.sys
  │ 
  │ The local name "snowflake.sys" in the root module represents provider
  │ "hashicorp/snowflake", but "snowflake.sys" in module.resources represents
  │ "snowflake-labs/snowflake".
  │ 
  │ Each provider has its own distinct configuration schema and provider types,
  │ so this module`s "snowflake.sys" can be assigned only a configuration for
  │ snowflake-labs/snowflake, which is not required by module.resources.
  ╵

This is very confusing to me. snowflake.sys in the root module is defined like so:

terraform {
  required_version = ">= 0.13"
  required_providers {
    snowflake = {
      source  = "snowflake-labs/snowflake"
      version = "0.83.1"
    }
    vault = {
      source  = "hashicorp/vault"
      version = "~> 3.0"
    }
  }
}

provider "vault" {
  namespace = "redacted"
}

data "vault_generic_secret" "vault_secrets_automation" {
  path = format("common/key-value/path/to/secret")
}

provider "snowflake" {
  user          = "user@example.com"
  alias         = "sys"
  account       = "xyz"
  private_key   = data.vault_generic_secret.vault_secrets_automation.data["key"]
  role          = "SYSADMIN"
  authenticator = "JWT"
}

As you can see I am using provider “snowflake-labs/snowflake” so I am confused by the error message:

The local name “snowflake.sys” in the root module represents provider “hashicorp/snowflake”

Can someone please explain to me why I’m getting this error because I simply don’t understand it.

Hi @jamiekt,

I’m not sure what’s going on there, does the terraform providers output give you any more information?

The only thing I can see is that you have a typo in your terraform block, which is missing a closing brace. That would normally cause parsing errors like Unclosed configuration block though, but maybe it’s related somehow.

Hi @jbardin ,
The typo was my fault. I copied the entirety of our terraform.tf file then removed the parts that were irrelevant for this question. I clearly made a mistake and removed one brace too many. I’ve now added it back the message above.

I ran terraform providers and got the same error message as above. However, I switched back to branch main in my repo, ran terraform providers again, and again got the same errors. This suggests that the cause of this error is not the change that I made in my branch.

I’ll continue investigating.