terraformsnowflake-cloud-data-platformterraform-providerresource-monitor

Terraform Snowflake provider change Error: Incompatible provider version


We have a requirement to change the provider from chanzuckerberg/snowflake to Snowflake-Labs/snowflake.

This change is done by changing

terraform {
  required_providers {
    snowflake = {
      source = "chanzuckerberg/snowflake"
      version = "0.25.36"
    }
  }
  backend "s3" {
  }
}
provider snowflake {
}

to

terraform {
  required_providers {
    snowflake = {
      source = "Snowflake-Labs/snowflake"
      version = "0.61.0"
    }
  }
  backend "s3" {
  }
}
provider snowflake {
}

We get the following error.

│ Warning: Additional provider information from registry
│ 
│ The remote registry returned warnings for
│ registry.terraform.io/chanzuckerberg/snowflake:
│ - For users on Terraform 0.13 or greater, this provider has moved to
│ Snowflake-Labs/snowflake. Please update your source in required_providers.
╵

╷
│ Error: Incompatible provider version
│ 
│ Provider registry.terraform.io/chanzuckerberg/snowflake v0.47.0 does not
│ have a package available for your current platform, linux_amd64.
│ 
│ Provider releases are separate from Terraform CLI releases, so not all
│ providers are available for all platforms. Other versions of this provider
│ may have different platforms supported.
╵

It sounds like the previous provider chanzuckerberg somewhere exists, thus causing an issue?

Any help is appreciated

terraform init and terraform plan works fine locally.

terraform providers provided (local run) the below

-- provider[registry.terraform.io/snowflake-labs/snowflake] 0.61.0

The error is at code build and our environment is an existing one.


Solution

  • If this configuration was already used to create some remote objects using the chanzuckerberg/snowflake provider then Terraform will be tracking in the state that those existing objects belong to that provider.

    Normally the process here would be to run terraform apply in a working directory where both providers are installed and then Terraform will notice that the configuration has changed to use Snowflake-Labs/snowflake instead, and so it will update the state to match.

    However, since the provider chanzuckerberg/snowflake seems to have no packages available for your current architecture, Terraform cannot perform that changeover automatically in this case.

    You can work around that by explicitly telling Terraform to rewrite the state to refer to the new provider:

    terraform state replace-provider 'chanzuckerberg/snowflake' 'snowflake-labs/snowflake'
    

    Normally when Terraform performs these changes automatically during terraform apply it will first check that the existing stored data makes sense for the new provider, but this command bypasses all of those checks and so it should avoid the need to install the old provider. This is safe only if the new provider has a compatible set of resource types.

    Once neither the configuration nor the state refer to chanzuckerberg/snowflake, the next time you run terraform init it should no longer try to install this provider and it will also remove the relevant entry from the .terraform.lock.hcl file.