Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
541 stars 416 forks source link

snowflake_managed_account unable to update NULL comments on managed accounts #2030

Open mswanson-mastery opened 1 year ago

mswanson-mastery commented 1 year ago

Provider Version

0.67.0

Terraform Version

v1.3.7

Describe the bug

When managing Snowflake accounts via "snowflake_account" we are unable to update NULL columns due to a type error. Some of our managed accounts have a simple string "SNOWFLAKE" as a comment and others are NULL - when trying to push a change up using the upgraded provider (upgraded from 0.64 to 0.67 for the behavior change on Snowflake) we encounter these errors:

│ Error: sql: Scan error on column index 6, name "comment": converting NULL to string is unsupported
│ 
│   with snowflake_account.managed_snowflake_accounts["ACCT-NAME"],
│   on accounts.tf line 13, in resource "snowflake_account" "managed_snowflake_accounts":
│   13: resource "snowflake_account" "managed_snowflake_accounts" {

below is a sanitized copy of our resource declaration:

resource "snowflake_account" "managed_snowflake_accounts" {
  for_each = local.environments

  provider             = snowflake.orgadmin
  name                 = each.value.snowflake_account_name
  admin_name           = "admin"
  admin_password       = random_password.managed_snowflake_account_passwords[each.key].result
  email                = ""
  edition              = "ENTERPRISE"
  region               = each.value.snowflake_region

  lifecycle {
    prevent_destroy = true
    ignore_changes = [
      admin_name,
      admin_password,
      comment,
      email,
      must_change_password
    ]
  }

}

Expected behavior

I would expect to be able to alter these comments or update them, if it is possible to do so.

mswanson-mastery commented 1 year ago

Just wanted to provide a quick follow-up note, I've been chatting with Snowflake support on this and updating comments as the ORGADMIN role is not possible for Managed Accounts. The Comment field can only be created.

If this isn't possible, please feel free to close this as an incorrectly reported bug.

nokernel commented 1 year ago

I believe it to be a bug. It is still present in 0.71.0.

I am using this resource since 0.51.0, and it's now broken even in 0.51.0, were also not setting the comment field in the terraform resource.

The comment value on the account is set to NULL and the terraform providers error out when it query the account info. Exactly with the same error as reported.