Use Snowflake with R2 to extend your global data lake
R2 is the ideal object storage platform to build data lakes. It’s infinitely scalable, highly durable (eleven 9's of annual durability), and has no egress fees. Zero egress fees mean zero vendor lock-in. You are free to use the tools you want to get the maximum value from your data.
Today we’re excited to announce our partnership with Snowflake so that you can use Snowflake to query data stored in your R2 data lake and load data from R2 into Snowflake. Organizations use Snowflake's Data Cloud to unite siloed data, discover, and securely share data, and execute diverse analytic workloads across multiple clouds.
One challenge of loading data into Snowflake database tables and querying external data lakes is the cost of data transfer. If your data is coming from a different cloud or even different region within the same cloud, this typically means you are paying an additional tax for each byte going into Snowflake. Pairing R2 and Snowflake lets you focus on getting valuable insights from your data, without having to worry about egress fees piling up.
Getting started
Sign up for R2 and create an API token
If you haven’t already, you’ll need to sign up for R2 and create a bucket. You’ll also need to create R2 security credentials for Snowflake following the steps below.
Generate an R2 token
- In the Cloudflare dashboard, select R2.
- Select Manage R2 API Tokens on the right side of the dashboard.
- Select Create API token.
- Optionally select the pencil icon or R2 Token text to edit your API token name.
- Under Permissions, select Edit.
- Select Create API Token.
You’ll need the Secret Access Key and Access Key ID to create an external stage in Snowflake.
Creating external stages in Snowflake
In Snowflake, stages refer to the location of data files in object storage. To create an external stage, you’ll need your bucket name and R2 credentials. Find your Cloudflare account ID in the dashboard.
CREATE STAGE my_r2_stage
URL = 's3compat://my_bucket/files/'
ENDPOINT = 'cloudflare_account_id.r2.cloudflarestorage.com'
CREDENTIALS = (AWS_KEY_ID = '1a2b3c...' AWS_SECRET_KEY = '4x5y6z...')
Note: You may need to contact your Snowflake account team to enable S3-compatible endpoints in Snowflake. Get more information here.
Loading data into Snowflake
To load data from your R2 data lake into Snowflake, use the COPY INTO