Skip to content

Snowflake

BInbox signs in to Snowflake with a key pair, the one way Snowflake has a service user sign in without a password. It signs a short-lived token (a JWT) with the private key, and Snowflake checks it against the public key registered on the user. BInbox runs queries through Snowflake’s SQL API on the warehouse you name, so that warehouse is billed for them.

On New connection, choose Snowflake.

Field What to enter
Account identifier The account’s identifier, such as myorg-myaccount. In Snowsight, open your account’s name at the bottom of the menu, then Account details, and copy the Account identifier. A locator with its region, such as xy12345.us-east-2.aws, also works.
Warehouse The warehouse that runs BInbox’s queries, BINBOX_WH below.
Database The database to read.
Schema Optional. The schema a table name without one is read from.
Role Optional. Leave empty to use the user’s default role.
How BInbox signs in A key pair. This is the only choice.
User name The Snowflake user the public key is registered on, BINBOX_READER below.
Private key (PEM) The private key, whole, with its BEGIN and END lines.
Passphrase Needed only if the private key is encrypted.
Terminal window
# An unencrypted key (leave Passphrase empty in BInbox)
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out binbox_key.p8 -nocrypt
# Or an encrypted key (openssl asks for a passphrase; paste it into Passphrase)
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out binbox_key.p8 -v2 aes256
openssl rsa -in binbox_key.p8 -pubout -out binbox_key.pub

Paste the whole of binbox_key.p8 into Private key (PEM). BInbox takes an RSA key whose first line is a BEGIN line for a PRIVATE KEY, an ENCRYPTED PRIVATE KEY or an RSA PRIVATE KEY, each between rows of five dashes.

Run these statements as ACCOUNTADMIN, or a role that may create users and grants, in a Snowsight worksheet or with snowsql. For the public key, use the text of binbox_key.pub between its BEGIN and END lines, with no line breaks.

CREATE ROLE BINBOX_ROLE;
CREATE USER BINBOX_READER TYPE = SERVICE DEFAULT_ROLE = BINBOX_ROLE RSA_PUBLIC_KEY = '<public key, one line>';
GRANT ROLE BINBOX_ROLE TO USER BINBOX_READER;
GRANT USAGE ON WAREHOUSE BINBOX_WH TO ROLE BINBOX_ROLE;
GRANT USAGE ON DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT USAGE ON ALL SCHEMAS IN DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT SELECT ON ALL TABLES IN DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT SELECT ON ALL VIEWS IN DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT SELECT ON FUTURE TABLES IN DATABASE <database> TO ROLE BINBOX_ROLE;
GRANT SELECT ON FUTURE VIEWS IN DATABASE <database> TO ROLE BINBOX_ROLE;

To keep BInbox’s queries off another team’s warehouse, make a small warehouse for BInbox:

CREATE WAREHOUSE BINBOX_WH WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE;

To read only some schemas, grant USAGE and SELECT on those schemas instead of the whole database. The same statements work from the command line: snowsql -a <account> -u <admin user> -f setup.sql.

Check that the key is registered on the user. The output must show the fingerprint RSA_PUBLIC_KEY_FP:

DESC USER BINBOX_READER;

If your account has a network policy, it must admit the connection. BInbox does not connect from a fixed address yet, so a policy that admits only listed addresses blocks it.

Grant Why BInbox needs it
USAGE on the warehouse To run a query.
USAGE on the database and its schemas To list the schemas.
SELECT on the tables and views to read To read them.

Do not grant OPERATE, MODIFY, CREATE, INSERT, UPDATE or DELETE.

Choose Test connection in BInbox. The first five permissions must be Granted, and the last is optional:

Permission Granted when
Sign in with the key pair Snowflake accepts the signed token for the user.
Run a query A SELECT of the current version runs.
Use the warehouse The role can use the warehouse, so CURRENT_WAREHOUSE() is not empty.
List the schemas in the database The role may use at least one schema besides INFORMATION_SCHEMA.
Read at least one table The role can see at least one table besides INFORMATION_SCHEMA’s.
Refuse a write, so SQL an author writes can run (optional) Snowflake refuses a delete of no rows from the first table the role can see, DELETE FROM <table> WHERE 1 = 0, with its access control error (003001). Snowflake has no read-only session, so the role’s grants are the control, and the test shows that one table refused. Without this, authors still pick tables, but cannot write a dataset’s SQL.

If Sign in with the key pair is refused, the public key on the user is not the pair of the private key you pasted, the account identifier is wrong, or the passphrase is wrong. The report quotes Snowflake’s error code.

An owner or admin opens the Data tab at app.binbox.ai, chooses Connect, then New connection, fills in the fields above, and chooses Test and save. Connections describes the screen.

Then an author sets up a dataset from one of the connection’s tables or views, as Pick a table describes.