docs: add env var instructions for snowflake

[DOCS-837]: https://hasurahq.atlassian.net/browse/DOCS-837?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8628
GitOrigin-RevId: 7441f15dea3aaf21d18df8b5606a4b4bd971c9d3
This commit is contained in:
Rob Dominguez 2023-04-11 06:06:03 -05:00 committed by hasura-bot
parent a1f82dde61
commit a5dec6ca72

View File

@ -24,22 +24,28 @@ create a new Hasura Cloud account.
Once you create a project on Hasura Cloud, hit the "Launch Console" button to open the Hasura Console for your project.
<Thumbnail src='/img/databases/data-connector/create-project.png' alt='Connect new or existing database' width='1000px' />
<Thumbnail
src="/img/databases/data-connector/create-project.png"
alt="Connect new or existing database"
width="1000px"
/>
### Step 2: Add your Snowflake database as a source to Hasura
:::info Note
:::info Prerequisite: Turn on the experimental features for GDC
** Step 2 Prerequisite: Turn on the experimental features for GDC**.
While the Snowflake Connector is in beta, the feature can only be enabled by turning on the _Experimental features for
GDC_ under the _Feature Flags_ section of the Console configuration page.
While the Snowflake Connector is in beta, the feature can only be enabled by turning on the _Experimental features
for GDC_ under the _Feature Flags_ section of the Console configuration page.
1. Click the gear icon in the top-right corner of your Cloud project <br/>
2. In the side navigation, click "Feature Flags" <br/>
3. Finally, toggle the "Experimental features for GDC" switch to enable <br/>
1) Click the gear icon in the top-right corner of your Cloud project <br/>
2) In the side navigation, click "Feature Flags" <br/>
3) Finally, toggle the "Experimental features for GDC" switch to enable <br/>
<Thumbnail src='/img/databases/data-connector/settings_feature-flags_2-18-0.png' alt='Turning on experimental features.' width='1000px' />
<Thumbnail
src="/img/databases/data-connector/settings_feature-flags_2-18-0.png"
alt="Turning on experimental features."
width="1000px"
/>
:::
@ -48,58 +54,83 @@ Head to the `Data > Manage databases` section on the Console to add your Snowfla
:::info Make sure your Snowflake service is reachable by Hasura Cloud:
1. **Allow public connections or
[whitelist the Hasura Cloud IP](/hasura-cloud/projects/create.mdx#cloud-projects-create-allow-nat-ip) on your [Snowflake
firewall](https://docs.snowflake.com/en/user-guide/network-policies.html):** This is good for testing and will allow you to quickly try out Hasura with your database!
2. **VPC peering:** VPC peering and private network access is available on Hasura Cloud paid tiers and is
recommended for production. Get in touch with us if you'd like to try this out against your existing databases.
[whitelist the Hasura Cloud IP](/hasura-cloud/projects/create.mdx#cloud-projects-create-allow-nat-ip) on your
[Snowflake firewall](https://docs.snowflake.com/en/user-guide/network-policies.html):** This is good for testing and
will allow you to quickly try out Hasura with your database!
2. **VPC peering:** VPC peering and private network access is available on Hasura Cloud paid tiers and is recommended
for production. Get in touch with us if you'd like to try this out against your existing databases.
:::
#### Step 2.1: Begin by clicking "Connect Database"
<Thumbnail src='/img/databases/data-connector/manage-databases.png' alt='Manage databases' width='1000px' />
<Thumbnail src="/img/databases/data-connector/manage-databases.png" alt="Manage databases" width="1000px" />
#### Step 2.2: Next, choose the `snowflake (Beta)` driver
<Thumbnail src='/img/databases/snowflake/choose-snowflake.png' alt='temp' width='1000px' />
<Thumbnail src="/img/databases/snowflake/choose-snowflake.png" alt="temp" width="1000px" />
#### Step 2.3: Enter your Snowflake JDBC Connection string
<Thumbnail
src='/img/databases/snowflake/database-config.png'
alt='Setting the Snowflake connection details.'
width='1000px'
src="/img/databases/snowflake/database-config.png"
alt="Setting the Snowflake connection details."
width="1000px"
/>
Snowflake JDBC connection strings have the [following formats](https://docs.snowflake.com/en/user-guide/jdbc-configure.html#examples):
Snowflake JDBC connection strings have the
[following formats](https://docs.snowflake.com/en/user-guide/jdbc-configure.html#examples):
- `jdbc:snowflake://myorganization-myaccount.snowflakecomputing.com/?user=peter&warehouse=mywh&db=mydb&schema=public`
- `jdbc:snowflake://xy12345.snowflakecomputing.com/?user=peter&warehouse=mywh&db=mydb&schema=public`
You can get your `account id` for the second syntax by logging in to Snowflake and navigating to `Admin -> Accounts`.
You can find more info on Snowflake's [JDBC Connection docs](https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string) here.
You can find more info on Snowflake's
[JDBC Connection docs](https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string) here.
Once you add the Snowflake service, you will find it listed as an available database on the sidebar.
:::info Setting the connection string as an environment variable
It's generally accepted that setting the connection string as an environment variable is a better practice as it's more
secure and prevents any secrets from being exposed in your instance's metadata.
An example would be to create a new
[environment variable](/deployment/graphql-engine-flags/index.mdx#using-environment-variables) called
`SNOWFLAKE_JDBC_URL` and set it equal to your JDBC connection string.
Then, export the metadata - in JSON form - using the Console's `Settings` page or by making a call using the
[metadata API](api-reference/metadata-api/manage-metadata.mdx#metadata-export-metadata) and add the following key-value
pair to the `metadata.json`'s `configuration` object:
```json
"template": "{\"fully_qualify_all_names\": false, \"jdbc_url\": \"{{getEnvironmentVariable(\"SNOWFLAKE_JDBC_URL\")}}\"}"
```
You can then apply the metadata to your instance by either using the Console's `Settings` page or by making a call using
the [metadata API](api-reference/metadata-api/manage-metadata.mdx#metadata-apply-metadata).
:::
### Step 3: Track existing tables
To query your Snowflake service using Hasura, you'll need to have existing tables to select. Those tables
will appear under the database as shown.
To query your Snowflake service using Hasura, you'll need to have existing tables to select. Those tables will appear
under the database as shown.
<Thumbnail src='/img/databases/snowflake/track-tables-1.png' alt='Tracking tables.' width='1000px' />
<Thumbnail src="/img/databases/snowflake/track-tables-1.png" alt="Tracking tables." width="1000px" />
You can select all or select individual tables to track. Click "Track Selected" for Hasura to introspect them and
create the corresponding GraphQL schema.
You can select all or select individual tables to track. Click "Track Selected" for Hasura to introspect them and create
the corresponding GraphQL schema.
<Thumbnail src='/img/databases/snowflake/track-tables-2.png' alt='Tracking tables selected.' width='1000px' />
<Thumbnail src="/img/databases/snowflake/track-tables-2.png" alt="Tracking tables selected." width="1000px" />
### Step 4: Try out a GraphQL query
Head to the `API` tab in the Console and try running a GraphQL query! Use the explorer sidebar on GraphQL to get help in
creating a GraphQL query.
<Thumbnail src='/img/databases/snowflake/query.png' alt='Try a GraphQL query' width='1000px' />
<Thumbnail src="/img/databases/snowflake/query.png" alt="Try a GraphQL query" width="1000px" />
## Keep up to date
@ -109,8 +140,7 @@ Currently, Hasura supports read-only queries, relationships, and permissions on
:::
If you'd like to stay informed about the status of Snowflake support, subscribe to our newsletter and join our
discord!
If you'd like to stay informed about the status of Snowflake support, subscribe to our newsletter and join our discord!
- [https://hasura.io/newsletter/](https://hasura.io/newsletter/)
- [https://discord.com/invite/hasura](https://discord.com/invite/hasura)