Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data source snowflake_current_role is incompatible with QUOTED_IDENTIFIERS_IGNORE_CASE=true #2208

Open
imre-kerr-sb1 opened this issue Nov 23, 2023 · 1 comment
Labels
bug Used to mark issues with provider's incorrect behavior category:provider_config

Comments

@imre-kerr-sb1
Copy link

imre-kerr-sb1 commented Nov 23, 2023

Terraform CLI and Provider Versions

Terraform v1.6.4
on linux_amd64

  • provider registry.terraform.io/snowflake-labs/snowflake v0.76.0

Terraform Configuration

terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-labs/snowflake"
      version = ">= 0.76.0"
    }
  }
}

provider "snowflake" {
  params = {
    quoted_identifiers_ignore_case = true
  }
}


data "snowflake_current_role" "current" {}

resource "snowflake_role" "test" {
  name = "TEST_ROLE"
}

resource "snowflake_role_grants" "test" {
  role_name = snowflake_role.test.name
  roles = [
    data.snowflake_current_role.current.name
  ]
}

Expected Behavior

TEST_ROLE should be granted to the current role.

Actual Behavior

Current role resolves to null, so the grant fails:

data.snowflake_current_role.current: Reading...
data.snowflake_current_role.current: Read complete after 0s

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform planned the following actions, but then encountered a problem:

  # snowflake_role.test will be created
  + resource "snowflake_role" "test" {
      + id   = (known after apply)
      + name = "TEST_ROLE"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Error: Null value found in list
│ 
│   with snowflake_role_grants.test,
│   on main.tf line 31, in resource "snowflake_role_grants" "test":
│   31:   roles = [
│   32:     data.snowflake_current_role.current.name
│   33:   ]
│ 
│ Null values are not allowed for this attribute value.
╵

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

Low

Logs

No response

Additional Information

In my example I set QUOTED_IDENTIFIERS_IGNORE_CASE as a session parameter, but in our real account it is set at the account level. Unfortunately it is outside our control.

We can work around this by setting it to false in session, but we're worried about what other issues might be introduced if we inadvertently create resources with lowercase names.

The cause seems to just be the column alias used in https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/snowflake/current_role.go

@imre-kerr-sb1 imre-kerr-sb1 added the bug Used to mark issues with provider's incorrect behavior label Nov 23, 2023
@imre-kerr-sb1
Copy link
Author

Seems like the exact same issue as #770

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior category:provider_config
Projects
None yet
Development

No branches or pull requests

2 participants