terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

Error: Incompatible provider version

Open reach2me opened this issue 1 year ago • 6 comments

Terraform CLI and Provider Versions

$ terraform version
Terraform v1.7.4
on linux_amd64

Terraform Configuration

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 3.67"
    }
    google-beta = {
      source  = "hashicorp/google-beta"
      version = "~> 3.67"
    }
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "0.86.0"
    }
  }
}

.gitlab-ci.yaml

stages:
  - "testing"

1_plan:
  image: xxxxxxxx:latest-full
  stage: "xxxx"
  tags:
    - cache
  variables:
    PUSH_AS_LATEST: "no"
    SNOWFLAKE_USER: ${SNOWFLAKE_USER}
    SNOWFLAKE_PASSWORD: ${SNOWFLAKE_PASSWORD}
  services:
    - name: docker:24.0.7-dind
      alias: dind
  script:
    - cd snowflake
    - export SNOWFLAKE_USER=${SNOWFLAKE_USER}
    - export SNOWFLAKE_PASSWORD=${SNOWFLAKE_PASSWORD}
    - "terraform init -upgrade"
    - "terraform state replace-provider 'chanzuckerberg/snowflake' 'Snowflake-Labs/snowflake'"
    - "terraform plan"
  only:
    - master
  when: manual

Expected Behavior

not expecting below error:

│ 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.

Actual Behavior

$ terraform init -upgrade

Initializing the backend...

Successfully configured the backend "gcs"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding latest version of chanzuckerberg/snowflake...
- Finding hashicorp/google versions matching "~> 3.67"...
- Finding hashicorp/google-beta versions matching "~> 3.67"...
- Finding snowflake-labs/snowflake versions matching "0.86.0"...
- Installing hashicorp/google v3.90.1...
- Installed hashicorp/google v3.90.1 (signed by HashiCorp)
- Installing hashicorp/google-beta v3.90.1...
- Installed hashicorp/google-beta v3.90.1 (signed by HashiCorp)
- Installing snowflake-labs/snowflake v0.86.0...
- Installed snowflake-labs/snowflake v0.86.0 (signed by a HashiCorp partner, key ID 5166D7352E69Axxx)

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
╷
│ 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.
╵

ERROR: Job failed: exit code 1

Steps to Reproduce

  1. terraform plan

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

reach2me avatar Feb 28 '24 12:02 reach2me

Hey @reach2me. Thanks for reaching out to us.

It seems that you were using the really old provider version (preSnowflake one) before. Did you check the CZI_UPGRADE doc?

sfc-gh-asawicki avatar Feb 28 '24 13:02 sfc-gh-asawicki

@sfc-gh-asawicki Problem is when running locally terraform its working as expected without issue but the issue with cicd pipeline. check my the terraform configuration above source = "Snowflake-Labs/snowflake". could be pipline somehow cached with old chanzuckerberg/snowflake

the issue might 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.

solution doesn't work which is here: https://stackoverflow.com/questions/75998221/terraform-snowflake-provider-change-error-incompatible-provider-version

terraform state replace-provider 'chanzuckerberg/snowflake' 'Snowflake-Labs/snowflake'

reach2me avatar Feb 28 '24 13:02 reach2me

Hey @reach2me. From what I see in your .gitlab-ci config, you have the incorrect order:

    - "terraform init -upgrade"
    - "terraform state replace-provider 'chanzuckerberg/snowflake' 'Snowflake-Labs/snowflake'"

the one listed in the docs is:

    - "terraform state replace-provider 'chanzuckerberg/snowflake' 'Snowflake-Labs/snowflake'"
    - "terraform init -upgrade"

Can you try if this helps?

sfc-gh-asawicki avatar Feb 28 '24 14:02 sfc-gh-asawicki

@sfc-gh-asawicki

thanks, after arranging in order, getting different error.


$ terraform state replace-provider 'chanzuckerberg/snowflake' 'Snowflake-Labs/snowflake'
Backend reinitialization required. Please run "terraform init".
Reason: Initial configuration of the requested backend "gcs"

The "backend" is the interface that Terraform uses to store state,
perform operations, etc. If this message is showing up, it means that the
Terraform configuration you're using is using a custom configuration for
the Terraform backend.

Changes to backend configurations require reinitialization. This allows
Terraform to set up the new configuration, copy existing state, etc. This is
only done during "terraform init". Please run that command now then try again.

If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.

Error loading the state: Initialization required. Please see the error message above.

Please ensure that your Terraform state exists and that you've
configured it properly. You can use the "-state" flag to point
Terraform at another state file.
ERROR: Job failed: exit code 1

reach2me avatar Feb 28 '24 14:02 reach2me

@reach2me it seems you are initializing the gcs backend for the first time. Is this really the case?

Also, I would advise bumping in smaller steps. There is a migration guide summarizing the manual changes needed between newer versions (https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#migration-guide). Please at least split the upgrade into the following steps:

  • change the provider only (no version bump, stay on 0.47.0, no additional changes beyond the ones needed for the https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/CZI_UPGRADE.md)
  • bump the version to 0.73.0
  • bump version by version according to the migration guidelines mentioned

sfc-gh-asawicki avatar Feb 28 '24 15:02 sfc-gh-asawicki

Hey @reach2me. Did you manage to migrate to the newest provider version using smaller steps?

sfc-gh-asawicki avatar Apr 10 '24 09:04 sfc-gh-asawicki

Closing due to inactivity. Please create a new issue if the problems persist in the newest provider version.

sfc-gh-asawicki avatar May 15 '24 08:05 sfc-gh-asawicki