Connect Snowflake to StackSpend
Track Snowflake spend with billed currency accuracy. Follow the step-by-step guide below.
StackSpend connects to Snowflake using billed currency data from organization usage views. Use a dedicated service user, grant organization billing access, and test the connection before syncing spend data.
Billed Currency Access Required
StackSpend reads from SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY. Your user must have a role that can access this view (Step 2). If only ACCOUNT_USAGE is available, StackSpend will tell you during the test — update your Snowflake grants before saving.
Step-by-step setup (start to finish)
Follow these steps in order. This guide assumes you are completing setup directly. Steps that require admin-level Snowflake privileges are marked.
Step 0: Gather the values you will paste into StackSpend
In Snowflake (Projects → Query data), run these two commands first:
Account Identifier
SELECT LOWER(CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME()) AS account_identifier;Warehouse
SHOW WAREHOUSES;Then run this verification block:
-- Account Identifier (recommended format)
SELECT LOWER(CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME()) AS account_identifier;
-- Find available warehouses
SHOW WAREHOUSES;
-- Verify billed-currency view exists and is accessible
SHOW DATABASES LIKE 'SNOWFLAKE';
SHOW SCHEMAS LIKE 'ORGANIZATION_USAGE' IN DATABASE SNOWFLAKE;
SHOW VIEWS LIKE 'USAGE_IN_CURRENCY_DAILY' IN SCHEMA SNOWFLAKE.ORGANIZATION_USAGE;
SELECT * FROM SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY LIMIT 10;Use the account identifier result, one warehouse name from SHOW WAREHOUSES, and your role in StackSpend.
Step 1: Create service user and base grants
To be completed by a Snowflake admin. In Snowflake, open Snowsight → Projects → Query data (or click + to create a SQL file). Run:
USE ROLE ACCOUNTADMIN;
CREATE USER IF NOT EXISTS stackspend_service_user
DEFAULT_WAREHOUSE = COMPUTE_WH
DEFAULT_ROLE = ORGADMIN
MUST_CHANGE_PASSWORD = FALSE;
GRANT ROLE ORGADMIN TO USER stackspend_service_user;
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE ORGADMIN;
SHOW USERS LIKE 'STACKSPEND_SERVICE_USER';Replace ORGADMIN and COMPUTE_WH with your organization's role and warehouse names if different.
Step 2: Generate key files on your computer
Open Terminal and run:
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pubThis creates rsa_key.p8 (private key) and rsa_key.pub (public key) in your current terminal folder.
To find them immediately, run:
pwd
ls -lah rsa_key.p8 rsa_key.pubOptional (Mac): copy private key to clipboard with pbcopy < rsa_key.p8.
Step 3: Attach your public key to the service user
To be completed by a Snowflake admin. Open rsa_key.pub, copy the key text between BEGIN PUBLIC KEY and END PUBLIC KEY, and run:
ALTER USER stackspend_service_user
SET RSA_PUBLIC_KEY = '<PASTE_PUBLIC_KEY_HERE>';Step 4: Confirm billed-currency view access
To be completed by a Snowflake admin. Confirm this user can query SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY.
Step 5: Add Snowflake in StackSpend
- Go to Settings → Providers → Add Provider → Snowflake
- Enter Account Identifier (example:
xy12345.us-east-1) - Enter Username:
stackspend_service_user - Enter Warehouse:
COMPUTE_WH(or your admin-provided value) - Enter Role:
ORGADMIN(or your admin-provided role) - Set Authentication Method to Key-pair (this must be selected to show the private key field)
- Paste the full contents of
rsa_key.p8into Private Key - Click Test Connection
- If test passes, click Save. If test fails, copy the full error and resolve it in Snowflake first.
Reference SQL (admin-only tasks)
USE ROLE ACCOUNTADMIN;
CREATE USER IF NOT EXISTS stackspend_service_user
DEFAULT_WAREHOUSE = COMPUTE_WH
DEFAULT_ROLE = ORGADMIN
MUST_CHANGE_PASSWORD = FALSE;
GRANT ROLE ORGADMIN TO USER stackspend_service_user;
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE ORGADMIN;
SHOW USERS LIKE 'STACKSPEND_SERVICE_USER';
ALTER USER stackspend_service_user
SET RSA_PUBLIC_KEY = '<PASTE_PUBLIC_KEY_HERE>';Troubleshooting
User does not exist or not authorized
Run Step 1 exactly, including SHOW USERS LIKE 'STACKSPEND_SERVICE_USER'. Ensure you are using an admin role such as ACCOUNTADMIN.
Unexpected 'LIKE' syntax error in SHOW commands
Use Snowflake clause order exactly: SHOW VIEWS LIKE 'USAGE_IN_CURRENCY_DAILY' IN SCHEMA SNOWFLAKE.ORGANIZATION_USAGE;
Private key field is not visible in StackSpend
Set Authentication Method to Key-pair. If still hidden, switch to password and back to key-pair once.
Private key or passphrase error
Confirm the PEM key is complete, the passphrase matches, and the Snowflake user has the corresponding public key assigned.
Connected, but billed currency access is missing
This means the user can authenticate, but cannot query USAGE_IN_CURRENCY_DAILY. Update the organization billing/viewer grants, then test again.
Warehouse or role errors
Check that the specified warehouse exists, the user can use it, and the optional role is valid for the session.
After connecting
- StackSpend syncs Snowflake spend from billed currency rows, not credit-only estimates
- The provider detail page shows whether the connection is in the expected currency-accurate mode
- You can set budgets and review Snowflake costs alongside your other cloud and AI providers