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 provider #4210

Merged
merged 2 commits into from
Jun 10, 2024
Merged

⭐️ snowflake provider #4210

merged 2 commits into from
Jun 10, 2024

Conversation

chris-rock
Copy link
Member

Snowflake Provider

cnquery shell snowflake

Required arguments:

  • --account - The Snowflake account name.
  • --region - The Snowflake region.
  • --user - The Snowflake username.
  • --role - The Snowflake role.

The easiest way to get the account name and region is to look at the URL when you log in to the Snowflake web interface. When clicking on the account icon you can copy the account URL that included the account name and region.

Password Authentication

Arguments:

  • --password - The Snowflake password.
  • --ask-pass - Prompt for the Snowflake password.
shell snowflake --account zi12345 --region us-central1.gcp --user CHRIS  --role ACCOUNTADMIN --ask-pass

To create a username and password, use Snowsight or using SQL.

Certificate Authentication

Arguments:

  • --private-key - The path to the private key file.
shell snowflake --account zi12345 --region us-central1.gcp --user CHRIS  --role ACCOUNTADMIN --private-key ~/.ssh/id_rsa

You need to generate a RSA key pair and assign the public key to your user via Snowsight.

Examples

Retrieve all users

cnquery> snowflake.account.users
snowflake.account.users: [
  0: snowflake.user name="CHRIS"
  1: snowflake.user name="DATAUSER"
  2: snowflake.user name="SNOWFLAKE"
]

Retrieve all users that have no MFA

cnquery> snowflake.account.users.where(extAuthnDuo == false)
snowflake.account.users.where: [
  0: snowflake.user name="CHRIS"
  1: snowflake.user name="DATAUSER"
  2: snowflake.user name="SNOWFLAKE"
]

Retrieve all users that have password authentication

cnquery> snowflake.account.users.where(hasPassword)
snowflake.account.users.where: [
  0: snowflake.user name="CHRIS"
  1: snowflake.user name="DATAUSER"
  2: snowflake.user name="SNOWFLAKE"
]

Retrieve all users that have certificate authentication

cnquery> snowflake.account.users.where(hasRsaPublicKey)
snowflake.account.users.where: [
  0: snowflake.user name="CHRIS"
]

Retrieve users that have not logged in for 30 days

cnquery> snowflake.account.users.where(time.now - lastSuccessLogin > time.day * 30) { lastSuccessLogin }
snowflake.account.users.where: [
  0: {
    lastSuccessLogin: 366 days 
  }
]

Check that SCIM is enabled

cnquery> snowflake.account.securityIntegrations.where(type == /SCIM/).any(enabled == true)
[failed] [].any()
  actual:   []

Check the retention time is greater 90 days

cnquery> snowflake.account.parameters.one(key == "DATA_RETENTION_TIME_IN_DAYS" && value >= 90)

Retrieve all databases

cnquery> snowflake.account.databases
snowflake.account.databases: [
  0: snowflake.database name="CNQUERY"
  1: snowflake.database name="SNOWFLAKE"
  2: snowflake.database name="SNOWFLAKE_SAMPLE_DATA"
]

This comment has been minimized.

@chris-rock chris-rock force-pushed the chris-rock/snowflake branch from 3e87e25 to 3d4c616 Compare June 9, 2024 22:07

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jun 9, 2024

Test Results

3 058 tests  ±0   3 057 ✅ ±0   1m 35s ⏱️ +3s
  361 suites +6       1 💤 ±0 
   27 files   +1       0 ❌ ±0 

Results for commit 1e1e3f2. ± Comparison against base commit 465329a.

♻️ This comment has been updated with latest results.

@chris-rock chris-rock force-pushed the chris-rock/snowflake branch from 3d4c616 to 5d2d1ff Compare June 9, 2024 22:12
@chris-rock chris-rock force-pushed the chris-rock/snowflake branch from 5d2d1ff to ed43aa6 Compare June 9, 2024 22:16
@imilchev
Copy link
Member

We should look into disabling the debug logs from the snowflake terraform provider. Not sure what is a good way of doing this. It seems like the use log.Printf which means we cannot just change the verbosity of the logger... https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/5df6d3d035d680c9d2a383c7835e90b9b93c56b9/pkg/sdk/client.go#L180C6-L180C12

Signed-off-by: Ivan Milchev <ivan@mondoo.com>
@imilchev imilchev merged commit c402834 into main Jun 10, 2024
15 checks passed
@imilchev imilchev deleted the chris-rock/snowflake branch June 10, 2024 11:24
@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants