terraform-provider-snowflake: err = missing destination name kind in *[]snowflake.Database

Provider Version

0.64

Terraform Version

1.4.6

Describe the bug Snowflake release 7.13 adds the kind column to the show databases command. This behavior change was enabled by default in the 7.19 release:

select current_version();
-- +-------------------+                                                           
-- | CURRENT_VERSION() |
-- |-------------------|
-- | 7.19.2            |
-- +-------------------+

I believe this is now causing the state refresh for our existing databases to fail:

Error: unable to scan row for SHOW DATABASES LIKE 'ANALYTICS' err = missing destination name kind in *[]snowflake.Database

  with snowflake_database.analytics,
  on databases.tf line 1, in resource "snowflake_database" "analytics":
   1: resource "snowflake_database" "analytics" {

Expected behavior

The state of the database refreshes successfully.

Code samples and commands

resource "snowflake_database" "analytics" {
  name                        = "ANALYTICS"
  data_retention_time_in_days = 14
  is_transient                = false
}

Additional context A patch for this change would be appreciated. In particular, https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1845 is a major friction to us upgrading beyond 0.64.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 22
  • Comments: 36 (5 by maintainers)

Most upvoted comments

Snowflake seems to have enabled bundle 2023_03 this week which is now in “opt-out period”.

In this bundle, there is a change on the SHOW DATABASES command which has a new colmun named KIND (more info on snowflake documentation). I suppose that this change is at the origin of our problems.

For my part, I have disabled this bundle and trouble was solved for us. Command to disable the bundle : select SYSTEM$DISABLE_BEHAVIOR_CHANGE_BUNDLE('2023_03');

Nevertheless, bundle will be enable by default in 2 months (without possibility to disable it) so I think that we will have to upgrade to a new release of the provider and for my part, I hope that issue #1845 will be solved…

In case anyone is interested, we managed to get around any grant revokes by doing this:

  1. disable behaviour change bundle 2023_03
  2. include explicit enable_multiple_grants = true (or false) with provider 0.64.0
  3. upgrade to provider 0.66.2 (-> no changes were stated in terraform plan)
  4. enable behaviour change bundle 2023_03

just to be sure we additionally included the ingnore_changes = [users] as was mentioned here

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn’t found in the scanned struct. We have changed that to not throw an error. If this field isn’t found, it will just set it to an empty string. Furthermore, we did add “Kind” https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

@sfc-gh-swinkler We also cannot upgrade to 0.66 as #1845 breaks our setup. Among other things, all the grants performed by AzureAD are dropped.

This started effecting us today on 0.64

This was fixed in 0.66 as part of the databases SDK refactoring: https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/1840. Essentially the driver we were using was throwing an error when a field wasn’t found in the scanned struct. We have changed that to not throw an error. If this field isn’t found, it will just set it to an empty string. Furthermore, we did add “Kind” https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

@sfc-gh-swinkler are there any plans to resolve #1845? This issue complicates upgrading from 0.64 to later versions.

Hitting the same issue on 0.63

Hi @sfc-gh-swinkler - thanks for approving #1872. A common pain-point from this thread is that several teams (myself included) can’t upgrade to version 0.65+ because of #1845. So if that issue won’t be resolved soon, is it possible to release something like a v0.64.1 that just adds the change from #1872 into 0.64.0, so that teams can use their current provider versions in the meantime?

Same to us. Without any change in the terraform config or in the snowflake platform ( current snowflake version 7.20.0)

0.61 provider version

with 0.61 current provider version, db’s are not recognized anymore . And it tries to create them:

   # snowflake_database.db["MY_DB"] will be created
  + resource "snowflake_database" "db" {
      + data_retention_time_in_days = 30
      + id                          = (known after apply)
      + is_transient                = false
      + name                        = "MY_DB"
    }

  # Plan: 18 to add, 0 to change, 0 to destroy. <--------- !!!!

0.65 provider version

with 0.65 provider version this error happens.

│ Error: unable to scan row for SHOW DATABASES LIKE 'MY_DB' err = missing destination name kind in *[]snowflake.Database
│ 
│   with snowflake_database.db["MY_DB"],
│   on db_creation.tf line 38, in resource "snowflake_database" "db":
│   38: resource "snowflake_database" "db" {
│ 

> 0.66 provider version

with 0.66.1 and 0.66.2 db problem seems to be fixed but now it want to change role_grants config .

It is adding a new parameter enable_multiple_grants = true and also trying to remove some of the users belonging to the role. This is a very big trouble.

  # snowflake_role_grants.role_grant["MY_ROL"] will be updated in-place
  ~ resource "snowflake_role_grants" "role_grant" {
      + enable_multiple_grants = true
        id                     = "MY_ROL||XXXXXXX,YYYYYYYY,ZZZZZZZ"
      ~ users                  = [
          - "XXXXXXX",
          - "YYYYYYY",
          - "ZZZZZZZ"
        ]
        # (2 unchanged attributes hidden)
    }


Any idea on how to continue working with terraform and snowflake??, I can not do new changes  because it will destroy valid snowflake configurations.

#1872 should fix it

same issue 0.61

As a work around, we have disabled bundle 2023_03 which appears to have resolved the issue for now:

select system$disable_behavior_change_bundle('2023_03');

Assuming this is fixed in a release before the opt out period has ended, we ideally would prefer to not have to remove and re-import most of the role grants in our account from terraform state to upgrade (https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1845).

In my current configuration we don’t use terraform to provision real users ( we have an Azure AD integration to automatically provision real users from the Azure AD ).

In this context, as a workaround to avoid removing users in the next terraform apply I’ve changed my snowflake_role_grants resource definition adding enable_multiple_grants = false and a ignore_changes for users in a lifecycle block

resource "snowflake_role_grants" "role_grant" {

  enable_multiple_grants = false
  role_name              = XXXX
  roles                  =  [ YYYY ]
  lifecycle {
    ignore_changes = [users]
  }

}

I hope this can help to other administrators in a similar context. ( maybe won’t be a good workaround if this terraform config is used also to provision generic services users for external tooling connection, something I will need in the future)

Same in 0.64 and can’t use 0.66 or higher for the moment because of #1845 which seems to remove all grants realized outside of terraform. So for the moment, we are totally blocked

Same same

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn’t found in the scanned struct. We have changed that to not throw an error. If this field isn’t found, it will just set it to an empty string. Furthermore, we did add “Kind” https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

Upgrading to 0.66.1 solved the issue for us.

i upgraded to 0.66.1 still not working. Everything was fine yesterday, stopped working today. terraform plan doesn’t recognize dbs already exist.

This was fixed in 0.66 as part of the databases SDK refactoring: https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/1840. Essentially the driver we were using was throwing an error when a field wasn’t found in the scanned struct. We have changed that to not throw an error. If this field isn’t found, it will just set it to an empty string. Furthermore, we did add “Kind” https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.