Runtime environment¶
Snowflake sets the listen address, connection details, and session token
for the running app. Declare
environment_variables
and
secrets
in app.yml.
Listen address¶
Read PORT and HOSTNAME and listen on that address:
HOSTNAME is the bind address. Users reach the app over HTTPS at a
*.snowflakecomputing.app URL; the app serves plain HTTP.
Built-in environment variables¶
Snowflake sets these at runtime. Read them from process.env (or
os.environ).
Listen
| Variable | Purpose |
|---|---|
PORT | The port to listen on |
HOSTNAME | The address to bind |
Account
| Variable | Purpose |
|---|---|
SNOWFLAKE_ACCOUNT | Account locator for the account the service runs in |
SNOWFLAKE_HOST | Hostname for a driver connection from the running app |
SNOWFLAKE_PORT | Connection port when Snowflake sets one (often 443) |
SNOWFLAKE_PROTOCOL | Connection protocol when it isn’t https (usually unset) |
SNOWFLAKE_AUTH_MODE | Always oauth |
SNOWFLAKE_INSECURE_MODE | Always true |
Service object
| Variable | Purpose |
|---|---|
SNOWFLAKE_DATABASE | Database that contains the Application Service |
SNOWFLAKE_SCHEMA | Schema that contains the Application Service |
SNOWFLAKE_SERVICE_NAME | Name of the Application Service |
Together they are the fully qualified name of the service:
Secret files¶
Snowflake mounts each secret listed under
secrets
in app.yml as one or more files under /secrets/<name>/, where <name> is
the mount name from the manifest. File content updates in place when
Snowflake rotates the secret.
The files written depend on the secret type:
| Secret type | Files under /secrets/<name>/ |
|---|---|
| Generic string | secret_string |
| Password | username, password |
| OAuth2 | access_token |
Read a generic string secret:
Read a password secret:
Read an OAuth2 access token:
Read secrets fresh on each use so a rotation takes effect without a redeploy. Don’t log secret values or return them in a response.
Session and caller tokens¶
Snowflake writes the credentials the app uses to query Snowflake:
- Session token. An OAuth token at
/snowflake/session/token. The token rotates, so read it fresh on each request. - Caller token. For caller’s rights queries, Snowflake adds an
Sf-Context-Current-User-TokenHTTP header to each incoming request. Combine the two tokens (serviceToken + "." + callerToken) and authenticate withauthenticator: "OAUTH".
lib/snowflake.ts
reads these for you. For which identity a query runs as and how to grant it
access, see
Query Snowflake.