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.pubCopy 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
| Field | Example | Notes |
|---|---|---|
| Account | xy12345.us-east-1 or myorg-myaccount | Your account identifier, the part of your Snowflake URL before .snowflakecomputing.com |
| Warehouse | COMPUTE_WH | |
| Username | CREDIBLE | |
| Password | Leave empty when you upload a private key | |
| Private Key | rsa_key.pem | Upload the file from Step 2 |
| Private Key Passphrase | Only if the key is encrypted |
Optional:
| Field | Example | What it does |
|---|---|---|
| Database | ANALYTICS_DB | The default database for unqualified table names |
| Schema | PUBLIC | The default schema |
| Role | CREDIBLE_READER | The role Credible uses. Without it, the user's default role applies |
| Response Timeout (ms) | 60000 | How 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
| Problem | Cause | Fix |
|---|---|---|
JWT token is invalid | The public key on the user does not match the uploaded private key | Run ALTER USER ... SET RSA_PUBLIC_KEY again with the matching .pub file |
Incorrect username or password | Wrong credentials, or the user is TYPE = SERVICE, which cannot use a password | Use a key pair |
No active warehouse selected | The role cannot use the warehouse | GRANT USAGE ON WAREHOUSE ... TO ROLE ... |
Object does not exist or not authorized | The role lacks USAGE on the database or schema, or SELECT on the table | Grant the missing privilege to the role |
IP ... is not allowed to access Snowflake | A Snowflake network policy blocks Credible | Add Credible's egress addresses to the policy. See Network Access |