Snowflake-Labs / terraform-provider-snowflake

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

data source "snowflake_current_account" returns null values #1366

Open dputnamfr opened 2 years ago

dputnamfr commented 2 years ago

Provider Version

0.46.0

Terraform Version

1.2.0

Describe the bug

data source "snowflake_current_account" appears to return null for "account" and "region".

Expected behavior

Using the snowflake provider 0.46.0 with the 'username', 'account' and 'password' and fields, I find that the datasource "snowflake_current_account" returns null for outputs 'account' and 'region'. Probably more.

Code samples and commands

Using a snowflake account in aws, ap-southeast-2, and passing in useful vars for username/account/password (corresponding to a user and account with ACCOUNT_ADMIN permissions):

Code:

provider "snowflake" {
  username = var.snowflake_username
  account  = var.snowflake_account_identifier #the organization-account style identifier
  password = var.snowflake_password
}

data "snowflake_current_account" "caller" {}

output "account" {
  value = data.snowflake_current_account.caller.account
}

output "region" {
  value = data.snowflake_current_account.caller.region
}

output "id" {
  value = data.snowflake_current_account.caller.id
}

output "url" {
  value = data.snowflake_current_account.caller.url
}

output "alldata" {
  value = data.snowflake_current_account.caller
}

Results:

$ terraform apply -var-file=/home/terraform/testvars

...general terraform output info here...

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Releasing state lock. This may take a few moments...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

alldata = {
  "account" = tostring(null)
  "id" = tostring(null)
  "region" = tostring(null)
  "url" = tostring(null)
}

Additional context

I love that you guys have a terraform provider. This makes me recommend you to my colleagues.

arnav13081994 commented 2 years ago

@dputnamfr I was facing the same issue. Run the command listed here

Basically your authentication is failing which is why you are getting null. I don't know why they don't throw an error.

dputnamfr commented 2 years ago

@arnav13081994 alas, still no luck. Thanks for the try, though.

I'm able to use the terraform provider to create a wealth of other snowflake things, so I think the authentication is okay. I'm thinking maybe they just don't have the caller working in ap-southeast-2

arnav13081994 commented 2 years ago

@arnav13081994 My snowflake region is ap-southeast-2 as well.

dputnamfr commented 2 years ago

That's very strange!

I assume you meant the command that provides the SYSADMIN and SECURITYADMIN roles (and PUBLIC role by default), but perhaps you meant I should change my authentication to ppk instead of password?

I'm definitely explicitly calling out the bug with the parameters 'authentication with password as ACCOUNTADMIN', so while I can try that when I get a hot sec, I wouldn't consider it an answer... it seems like this should absolutely be an allowable thing, yeah?

raaghul-umapathy commented 1 year ago

I'm facing the same issue.