Connect GX Cloud to Snowflake
To validate data stored in a Snowflake data warehouse from GX Cloud, you must add the GX Agent to your production environment. The GX Agent acts as an intermediary between GX Cloud and Snowflake and allows you to securely access and validate your data in GX Cloud.
New to GX Cloud and not sure that it's the right solution for your organization? See Try GX Cloud.
Prerequisites
You have a GX Cloud Beta account with Admin or Editor permissions.
You have a Snowflake database, schema, and table.
You have a Snowflake account with USAGE privileges on the table, database, and schema you are validating, and you have SELECT privileges on the table you are validating. To improve data security, GX recommends using a separate Snowflake user service account to connect to GX Cloud.
You know your Snowflake password.
You have stopped all local running instances of the GX Agent.
Prepare your Snowflake environment
You can use an existing Snowflake warehouse, but GX recommends creating a separate warehouse for GX Cloud to simplify cost management and optimize performance.
In Snowflake Snowsight, click Worksheets > Add > SQL Worksheet.
Copy and paste the following code into the SQL worksheet:
use role accountadmin;
create user gx_user password="secure_password";
create role gx_role;
grant role gx_role to user gx_user;Replace
secure_password
with your value.Select Run All to define your user password, create a new GX role (
gx_role
), and assign the password and role to a new user (gx_user
).Copy the following code and paste it into the SQL worksheet:
create warehouse gx_wh
warehouse_size=xsmall
auto_suspend=10
auto_resume=true
initially_suspended=true;The settings in the code example optimize cost and performance. Adjust them to suit your business requirements.
Select Run All to create a new warehouse (
gx_wh
) for the GX Agent.Copy the following code and paste it into the SQL worksheet:
grant usage, operate on warehouse gx_wh to role gx_role;
grant usage on database "database_name" to role gx_role;
grant usage on schema "database_name.schema_name" to role gx_role;
grant select on all tables in schema "database_name.schema_name" to role gx_role;
grant select on future tables in schema "database_name.schema_name" to role gx_role;grant select on future tables in schema "database_name.schema_name" to role gx_role;
is optional and gives the user with thegx_role
role access to all future tables in the defined schema.Replace
database_name
andschema_name
with the names of the database and schema you want to access in GX Cloud.Select Run All to allow the user with the
gx_role
role to access data on the Snowflake database and schema.
Get your GX Cloud access token and organization ID
You'll need your access token and organization ID to set your access credentials. Don't commit your access credentials to your version control software.
In GX Cloud, click Settings > Tokens.
In the User access tokens pane, click Create user access token.
In the Token name field, enter a name for the token that will help you quickly identify it.
Click Create.
Copy and then paste the user access token into a temporary file. The token can't be retrieved after you close the dialog.
Click Close.
Copy the value in the Organization ID field into the temporary file with your access token and then save the file.
GX recommends deleting the temporary file after you set the environment variables.
Deploy the GX Agent
You deploy and run the GX Agent within your production cloud services environment. You can deploy the GX Agent container in any environment where you can run Docker container images or create Kubernetes clusters.
To learn how to deploy a Docker container image in a specific environment, see the following documentation:
You can deploy the GX Agent in any environment in which you create Kubernetes clusters. For example:
Any Kubernetes cluster version 1.21 or greater which uses standard Kubernetes
- Docker
- Kubernetes
Download the GX Agent Docker container image from Docker Hub.
After configuring your cloud service to run Docker containers, run the following Docker command to start the GX Agent:
Terminal inputdocker run -it \
-e GX_CLOUD_ACCESS_TOKEN= YOUR_ACCESS_TOKEN \
-e GX_CLOUD_ORGANIZATION_ID= YOUR_ORGANIZATION_ID \
greatexpectations/agent:latestReplace
YOUR_ACCESS_TOKEN
andYOUR_ORGANIZATION_ID
with the values you copied previously.Optional. If you created a temporary file to record your user access token and Organization ID, delete it.
Optional. Run the following command to use the GX Agent image as the base image and optionally add custom commands:
Terminal inputFROM greatexpectations/agent
RUN echo "custom_commands"Optional. Run the following command to rebuild the Docker image:
Terminal inputdocker build -t myorg/agent
Optional. Run
docker ps
or open Docker Desktop to confirm the agent is running.
Install kubectl. See Install Tools.
Run the following command to provide the access credentials to the Kubernetes container:
kubectl create secret generic gx-agent-secret \
--from-literal=GX_CLOUD_ORGANIZATION_ID=YOUR_ORGANIZATION_ID \
--from-literal=GX_CLOUD_ACCESS_TOKEN=YOUR_ACCESS_TOKEN \Replace
YOUR_ORGANIZATION_ID
andYOUR_ACCESS_TOKEN
with the values you copied previously.Optional. If you created a temporary file to record your user access token and Organization ID, delete it.
Create and save a file named
deployment.yaml
, with the following configuration:apiVersion: apps/v1
kind: Deployment
metadata:
name: gx-agent
labels:
app: gx-agent
spec:
replicas: 1
selector:
matchLabels:
app: gx-agent
template:
metadata:
labels:
app: gx-agent
spec:
containers:
name: gx-agent
image: greatexpectations/agent:latest
envFrom:
secretRef:
name: gx-agent-secretRun the following command to use the
deployment.yaml
configuration file to deploy the GX Agent:kubectl apply -f deployment.yaml
Optional. Run the following command to confirm the agent is running:
kubectl logs -l app=gx-agent
Optional. Run the following command to terminate running resources gracefully:
kubectl delete -f deployment.yaml
kubectl delete secret gx-agent-secret