Snowflake

Connect Snowflake to Credible with a key pair or a password

To connect Snowflake you need an account identifier, a warehouse, and a user that signs in with a key pair or a password. Use a key pair: Snowflake is phasing out password-only sign-in for service users.

Step 1: Create a Role and User

Run this in a Snowflake worksheet as an administrator, replacing the warehouse, database and names:

CREATE ROLE credible_reader;
GRANT USAGE ON WAREHOUSE compute_wh TO ROLE credible_reader;
GRANT USAGE ON DATABASE analytics_db TO ROLE credible_reader;
GRANT USAGE ON ALL SCHEMAS IN DATABASE analytics_db TO ROLE credible_reader;
GRANT SELECT ON ALL TABLES IN DATABASE analytics_db TO ROLE credible_reader;
GRANT SELECT ON FUTURE TABLES IN DATABASE analytics_db TO ROLE credible_reader;

CREATE USER credible TYPE = SERVICE DEFAULT_ROLE = credible_reader DEFAULT_WAREHOUSE = compute_wh;
GRANT ROLE credible_reader TO USER credible;

Step 2: Set Up a Key Pair

Generate a private key and its public key on your machine:

openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.pem -nocrypt
openssl rsa -in rsa_key.pem -pubout -out rsa_key.pub

Copy the contents of rsa_key.pub without the BEGIN and END lines, and assign it to the user:

ALTER USER credible SET RSA_PUBLIC_KEY = 'MIIBIjANBgkqh...';

To protect the private key with a passphrase, leave out -nocrypt and enter the passphrase in Credible as well.

The upload accepts .pem and .key files. Keep rsa_key.pem out of version control.

Step 3: Connect in Credible

FieldExampleNotes
Accountxy12345.us-east-1 or myorg-myaccountYour account identifier, the part of your Snowflake URL before .snowflakecomputing.com
WarehouseCOMPUTE_WH
UsernameCREDIBLE
PasswordLeave empty when you upload a private key
Private Keyrsa_key.pemUpload the file from Step 2
Private Key PassphraseOnly if the key is encrypted

Optional:

FieldExampleWhat it does
DatabaseANALYTICS_DBThe default database for unqualified table names
SchemaPUBLICThe default schema
RoleCREDIBLE_READERThe role Credible uses. Without it, the user's default role applies
Response Timeout (ms)60000How long Credible waits for a query's response

From the CLI

To add the connection with cred add connection, put an entry like this in the JSON file:

[
  {
    "name": "warehouse",
    "type": "snowflake",
    "snowflakeConnection": {
      "account": "myorg-myaccount",
      "username": "CREDIBLE",
      "privateKey": "-----BEGIN PRIVATE KEY-----\nMIIEv...\n-----END PRIVATE KEY-----\n",
      "warehouse": "COMPUTE_WH",
      "role": "CREDIBLE_READER"
    }
  }
]

privateKey holds the contents of rsa_key.pem as one string, with each line break written as \n. Use password instead for password sign-in. The other settings are privateKeyPass, database, schema and responseTimeoutMilliseconds.

Troubleshooting

ProblemCauseFix
JWT token is invalidThe public key on the user does not match the uploaded private keyRun ALTER USER ... SET RSA_PUBLIC_KEY again with the matching .pub file
Incorrect username or passwordWrong credentials, or the user is TYPE = SERVICE, which cannot use a passwordUse a key pair
No active warehouse selectedThe role cannot use the warehouseGRANT USAGE ON WAREHOUSE ... TO ROLE ...
Object does not exist or not authorizedThe role lacks USAGE on the database or schema, or SELECT on the tableGrant the missing privilege to the role
IP ... is not allowed to access SnowflakeA Snowflake network policy blocks CredibleAdd Credible's egress addresses to the policy. See Network Access

Next Steps

On this page