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

snowflake_databases does not return any databases #1383

Closed
jifeous opened this issue Nov 22, 2022 · 8 comments
Closed

snowflake_databases does not return any databases #1383

jifeous opened this issue Nov 22, 2022 · 8 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@jifeous
Copy link

jifeous commented Nov 22, 2022

Provider Version

Terraform v1.3.2
on windows_amd64

  • provider registry.terraform.io/hashicorp/aws v4.40.0
  • provider registry.terraform.io/snowflake-labs/snowflake v0.52.0

Describe the bug

Using the snowflake_databases and snowflake_database data provider returns only nulls and does not return the expected db. If I check the snowflake query history I can see that it has run the correct sql "SHOW DATABASES LIKE "MYDB"".

Expected behavior

Returns the db so that I can use it to create a schema

Code samples and commands

data "snowflake_database" "domain" {
name = "MYDB"
}

output "snowflake_database" {
description = "Where is my db?"
value = data.snowflake_database.domain
}

@jifeous jifeous added the bug Used to mark issues with provider's incorrect behavior label Nov 22, 2022
@bennylu2
Copy link
Contributor

This sounds like a permission issue. Have you confirmed the role you're using has access to list the db?

@jifeous
Copy link
Author

jifeous commented Dec 19, 2022 via email

@jag-super
Copy link

jag-super commented Dec 22, 2022

I am also facing the same issue, I can confirm the role is correct and can see SHOW DATABASES LIKE "XXX" being executed under the correct role and return data. Other data sources like snowflake_role are working fine.

I'm not sure if this of relevance, but SHOW DATABASES LIKE "XXX" is has an extra column called resource_group being returned, this is not in the database struct.

@bennylu2
Copy link
Contributor

bennylu2 commented Jan 7, 2023

data "snowflake_database" "domain" {
  name = "TEST"
}

output "snowflake_database" {
  value = data.snowflake_database.domain
}
Changes to Outputs:
  + snowflake_database = {
      + comment        = "Snowflake database for TEST"
      + created_on     = "2021-10-21T13:35:25.113-07:00"
      + id             = "TEST"
      + is_current     = false
      + is_default     = false
      + name           = "TEST"
      + options        = ""
      + origin         = ""
      + owner          = "SYSADMIN"
      + retention_time = 30
    }

I'm unable to reproduce this bug. I would confirm that the role is able to list the database

One thing to note is the provider puts double-quotes to qualify everything so it is case sensitive. For example if you created your database as "test" you need to pass "test" and not "TEST" to the data source

@jifeous
Copy link
Author

jifeous commented Feb 7, 2023

The more general case is that no databases are returned from the snowflake_databases data provider

data "snowflake_databases" "this" {}

output "databases" {
  description = "Current Databases"
  value = data.snowflake_databases.this
}

Outputs:

databases = {
  "databases" = tolist(null) /* of object */
  "id" = tostring(null)
}

I can see the query in Snowflake and it returns the correct list of databases. It doesn't show in the terraform state.

I don't know what the difference could be

@jifeous jifeous closed this as completed Oct 27, 2023
@brettwatkins-Built
Copy link

@jifeous @jag-super @bennylu2 did you ever figure out what the issue here was? I'm running into the same thing

@jag-super
Copy link

@brettwatkins-Built No I didn't, you may want to try the latest provider version, as I was using a very old one and there have been changes.

@jifeous
Copy link
Author

jifeous commented Nov 23, 2023 via email

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
Projects
None yet
Development

No branches or pull requests

4 participants