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

[Bug]: Error when using data source snowflake_users

Open calleo opened this issue 1 year ago • 1 comments

Terraform CLI Version

1.6.6

Terraform Provider Version

0.92.0

Terraform Configuration

data "snowflake_users" "all_users" {
  pattern = "%MATSMART%"
}

Category

category:data_source

Object type(s)

data_source:users

Expected Behavior

I expect the data source to return a list of users, since the there are users matching the pattern.

Actual Behavior

null is returned.

Steps to Reproduce

Snowflake version: 8.23.5

  1. Create a user with the name "[email protected]"
  2. Use the resource as specified above, it should return the user you just created

How much impact is this issue causing?

Medium

Logs

https://gist.github.com/calleo/9b37c61b37eb138c16518bbc19c50d86

Additional Information

Looks like a problem with parsing the output of SHOW USERS. I have tried executing the exact same SQL statement, with the same user and role, and can see that it actually returns users.

My initial thought was that the disabled column contained null values, but I can also see true/false.

Would you like to implement a fix?

  • [ ] Yeah, I'll take it 😎

calleo avatar Jul 01 '24 19:07 calleo

Hey @calleo . Thanks for reaching out to us.

The user datasource will be redesigned as part of https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#preparing-essential-ga-objects-for-the-provider-v1. I will link this issue to https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/ESSENTIAL_GA_OBJECTS.MD. As a workaround, you can use unsafe_execute with query parameter.

sfc-gh-jmichalak avatar Jul 02 '24 07:07 sfc-gh-jmichalak

I am having the same issue at the moment, this used to work up to one month ago from the date, I guess there were some changes on the API in Snowflake side.

In our case we are using the TF provider 0.89.0

Also seems like the reply from the api gives some fields as null while running SHOW USERS LIKE 'MY_USER' from the UI actually returns those fields as true/false

Screenshot 2024-07-04 at 10 46 01

sebasziegler avatar Jul 04 '24 08:07 sebasziegler

Hey @calleo. We have just released v0.95.0 of the provider. It contains a reworked snowflake_users data source. Please consult the migration guide.

sfc-gh-asawicki avatar Sep 04 '24 17:09 sfc-gh-asawicki

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

sfc-gh-asawicki avatar Oct 15 '24 13:10 sfc-gh-asawicki