> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jedify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake

> Connect Snowflake with no key: a Snowflake service user trusts your cluster, then you declare the source.

Your cluster signs a token for the application's Kubernetes service account, and a Snowflake service user trusts that cluster and that service account. Jedify presents the token instead of a password, so no Snowflake credential exists anywhere.

## 1. Read your cluster's issuer

```sh theme={null}
tofu -chdir=terraform output -raw oidc_issuer
```

Expected: `https://container.googleapis.com/v1/projects/<project>/locations/<region>/clusters/<name>`. It stays the same if you rebuild the cluster under the same name.

## 2. Create the service user

A Snowflake administrator runs this, with your issuer:

```sql theme={null}
CREATE USER JEDIFY_SVC
  WORKLOAD_IDENTITY = (
    TYPE = OIDC
    ISSUER = '<your issuer>'
    SUBJECT = 'system:serviceaccount:jedify-be:jedify-be'
  )
  TYPE = SERVICE
  DEFAULT_ROLE = JEDIFY_ROLE
  DEFAULT_WAREHOUSE = JEDIFY_WH;
GRANT ROLE JEDIFY_ROLE TO USER JEDIFY_SVC;
```

Give `JEDIFY_ROLE` `USAGE` on the warehouse, the database and its schemas, and `SELECT` on the tables Jedify should read, as you would for any service user. Workload identity works only for users of `TYPE = SERVICE`.

Check it in Snowflake:

```sql theme={null}
SHOW USER WORKLOAD IDENTITY AUTHENTICATION METHODS FOR USER JEDIFY_SVC;
```

Expected: one identity of type `OIDC`, with your issuer and the subject above.

> [!NOTE]
>
> Managing Snowflake with OpenTofu? The Snowflake provider's `snowflake_service_user` takes the same trust as `default_workload_identity { oidc { issuer, subject } }`. Provider 2.22.0 needs `experimental_features_enabled = ["USER_ENABLE_DEFAULT_WORKLOAD_IDENTITY"]`.

> [!WARNING]
>
> Use `TYPE = OIDC`, whichever cloud hosts your Snowflake account. Jedify signs in with its pods' Kubernetes token, so a user that trusts an AWS role, a Google service account or an Azure managed identity (`TYPE = AWS`, `GCP` or `AZURE`) refuses it.

## 3. Let the cluster reach Snowflake

Jedify calls every host `SELECT SYSTEM$ALLOWLIST()` returns for your account.

* **In a network OpenTofu created**, Cloud NAT lets the calls out. There is nothing to do.
* **In your own network**, your network team allows those hosts out. The preflight checks one from the install host: add `--egress <account>.snowflakecomputing.com` to the command in [Requirements](https://docs.jedify.com/self-hosted/gcp/requirements.md#check-before-you-start).

If a Snowflake network policy limits the addresses your account accepts, see [Fixed addresses for allowlists](https://docs.jedify.com/self-hosted/gcp/install/existing-network.md#fixed-addresses-for-allowlists).

## 4. Declare the source

```yaml theme={null}
spec:
  dataSources:
    - name: snowflake
      type: snowflake
      workloadIdentity:
        settings:
          account: acme-xy12345   # <organization>-<account>
          user: JEDIFY_SVC
          warehouse: JEDIFY_WH
          role: JEDIFY_ROLE
```

| Setting | Required | Meaning |
| - | - | - |
| `account` | Yes | Your account identifier, `<organization>-<account>` |
| `user` | Yes | The service user from step 2 |
| `warehouse` | Yes | The warehouse Jedify's queries run on |
| `role` | No | The role to use, when it isn't the user's default |
| `database`, `schema` | No | A default database and schema |

## 5. Check it

```sh theme={null}
kubectl -n jedify get jedify jedify \
  -o jsonpath='{range .status.dataSources[*]}{.name}{"\t"}{.state}{"\t"}{.message}{"\n"}{end}'
```

Expected: `snowflake   Connected`.

## When it fails

| Message | Fix |
| - | - |
| Snowflake refuses the sign-in | The user's issuer or subject differs from your cluster's, or its identity isn't `TYPE = OIDC`. Compare with the `SHOW` command in step 2. |
| A refusal about the JWT, right after the cluster was rebuilt | Nothing. Snowflake caches your issuer's signing keys for some minutes, and the operator tries again on its own. |
| `099706` when you create the user | Another user in your Snowflake account already trusts this issuer and subject. Use that user, or remove its workload identity first. |
| `workload_identity cannot be combined with private_key or passphrase` | A source uses one way to sign in. Remove the key from it. |

To change an existing user's trust to OIDC:

```sql theme={null}
ALTER USER JEDIFY_SVC UNSET WORKLOAD_IDENTITY;
ALTER USER JEDIFY_SVC SET WORKLOAD_IDENTITY = (
  TYPE = OIDC
  ISSUER = '<your issuer>'
  SUBJECT = 'system:serviceaccount:jedify-be:jedify-be'
);
```

## With a key pair

A service user with a key pair works too. Prefer no key where you can: a key is a secret that can leak and has to be rotated.

The credentials are one JSON object:

| Key | Required | Meaning |
| - | - | - |
| `account` | Yes | Your account identifier, `<organization>-<account>` |
| `user` | Yes | The service user, with your public key set on it |
| `warehouse` | Yes | The warehouse Jedify's queries run on |
| `private_key` | Yes | The private key, as PEM text |
| `passphrase` | No | The private key's passphrase, if it has one |
| `role` | No | The role to use, when it isn't the user's default |
| `database`, `schema` | No | A default database and schema |

Store it in Secret Manager straight from the key file, so the key never passes through your shell:

```sh theme={null}
jq -n --rawfile key rsa_key.p8 \
  '{account: "acme-xy12345", user: "JEDIFY_SVC", warehouse: "JEDIFY_WH",
    role: "JEDIFY_ROLE", private_key: $key}' \
  | gcloud secrets create jedify-snowflake --data-file=- --project=acme-jedify
```

Then declare it under `credentials` in place of `workloadIdentity`:

```yaml theme={null}
spec:
  dataSources:
    - name: snowflake
      type: snowflake
      credentials:
        externalSecret:
          remoteRef: { key: jedify-snowflake }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.