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

Provider incorrectly marks snowflake_user.name as sensitive #2662

Closed
qbatten opened this issue Mar 28, 2024 · 4 comments
Closed

Provider incorrectly marks snowflake_user.name as sensitive #2662

qbatten opened this issue Mar 28, 2024 · 4 comments
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:user Issue connected to the snowflake_user resource

Comments

@qbatten
Copy link

qbatten commented Mar 28, 2024

Terraform CLI and Provider Versions

❯ terraform version
Terraform v1.6.6
on darwin_arm64

  • provider registry.terraform.io/airbytehq/airbyte v0.4.1
  • provider registry.terraform.io/snowflake-labs/snowflake v0.87.2

Your version of Terraform is out of date! The latest version
is 1.7.5. You can update by downloading from https://www.terraform.io/downloads.html

Terraform Configuration

terraform {
  required_version = "1.6.6"
  required_providers {

    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "0.87.2"
    }
  }
}

provider "snowflake" {
  account  = local.snowflake_creds.account_id
  role     = "USERADMIN"
  alias    = "useradmin"
}


resource "snowflake_user" "user" {
  name              = "USER"
  login_name        = "[email protected]"
  provider          = snowflake.useradmin
}

locals {
  some_users = toset([
    snowflake_user.user.name,
  ])
}

resource "snowflake_grant_account_role" "grant_role_to_users" {
  for_each = local.some_users
  provider   = snowflake.useradmin
  role_name  = "THE_ROLE"
  user_name  = each.key
}

Expected Behavior

I expect this to work. The list of user's names should not be marked sensitive, and the role should be granted. User names are not sensitive data, Snowflake says as such here ("Usernames are not sensitive data and are returned by other commands and functions"). I don't believe I've encountered any other providers that mark usernames as sensitive. But it seems that snowflake_user.name is indeed considered sensitive for this provider? (I don't know much Go, so hopefully I'm linking to the right line.)

I'm wondering if this PR actually meant to un-sensitive-ize name instead of login_name and a mistake was made? According to Snowflake, login_name is more sensitive than name. And name is the internal identifier for a user, not login_name, so by making name sensitive, it makes it impossible to do simple references to users (like I'm trying to do here), while login_name being marked sensitive wouldn't have that kind of impact.

Actual Behavior

Instead, the plan is failing due to the below error, because user.name is marked as sensitive. I saw & commented on this older issue, which the conversation made seem like it was resolved... but it doesn't seem to have been correctly resolved. It looks like login_name got changed to not-sensitive, but name is still sensitive?

╷
│ Error: Invalid for_each argument
│ 
│   on snowflake.tf line 162, in resource "snowflake_grant_account_role" "grant_analyze_to_analyzers":
│  162:   for_each = local.some_users
│     ├────────────────
│     │ local.some_users has a sensitive value
│ 
│ Sensitive values, or values derived from sensitive values, cannot be used
│ as for_each arguments. If used, the sensitive value could be exposed as a
│ resource instance key.

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

Thanks for you help!

@qbatten qbatten added the bug Used to mark issues with provider's incorrect behavior label Mar 28, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @qbatten. Thanks for reaching out to us.

We will address it during the resources redesign: https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#supporting-all-snowflake-ga-features.

@sfc-gh-jcieslak sfc-gh-jcieslak added resource:user Issue connected to the snowflake_user resource category:resource labels May 20, 2024
sfc-gh-asawicki added a commit that referenced this issue Aug 23, 2024
sfc-gh-asawicki added a commit that referenced this issue Aug 28, 2024
Fix known user resource-connected issues:
- Change the sensitiveness of name and login_name (References: #2662
#2668)
- Handle "null" properly for the nullable bool text attributes in user
(References: #2817)
- Fix diff suppression for default_x in user resource (References:
#2836)
- Update the migration guide (References #2938 #2942)
- Fix incorrect state after failed to alter (References #2970)
- Confirm the problem with the computed disabled attribute (References
#1572)
- Confirm that the problem with the null-out password was already solved
(References #1535)
- Add TODO to handle days to expiry in user (References #1155)

The next 2 PRs will contain:
- adjusting user resource to our rework conventions (also adding
additional fields and handling #1155 and #1572)
- adjusting user datasource (will handle #2902)

User rework will not include handling new types of users (service,
legacy service); this will be done a bit later.
@sfc-gh-asawicki
Copy link
Collaborator

Hey @qbatten, the fix was included in #3013 and will be released in v0.95.0 today or tomorrow (we have to wrap up a few other PRs before making a release). Please check the migration guide and report any problems.

@sfc-gh-asawicki
Copy link
Collaborator

Hey @qbatten.
We have just released v0.95.0 of the provider. It contains a reworked snowflake_user resource. Please consult the migration guide.

@sfc-gh-asawicki
Copy link
Collaborator

Closing the issue due to inactivity. Please create a new one if the issue persists in the newest version of the provider.

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:resource resource:user Issue connected to the snowflake_user resource
Projects
None yet
Development

No branches or pull requests

3 participants