Let's dive into methods of connecting dbt™ to Snowflake and how Paradime can significantly ease the process.
Ready to supercharge your data transformations? Let's dive into connecting dbt™ to Snowflake. We'll cover three rock-solid methods: username/password, OAuth, and key pair authentication in this guide. Buckle up!
Simple and straightforward, but watch out for security risks.
Here's how to set it up in your profiles.yml:
1my_snowflake_profile:
2 target: dev
3 outputs:
4 dev:
5 type: snowflake
6 account: your_account.region
7 user: your_username
8 password: your_password
9 role: your_role
10 database: your_database
11 warehouse: your_warehouse
12 schema: your_schema
13 threads: 4
Working with YAML file and storing username and passwords in local machines is not recommended and poses significant security risks. So, in Paradime we make the process as easy as filling up a form and we generate and store the profiles.yaml securely in the cloud. See how to setup Snowflake using Username-Password in Paradime.
OAuth is the way to go for enhanced security.
1-- Create OAuth client
2CREATE SECURITY INTEGRATION dbt_oauth
3 TYPE = OAUTH
4 ENABLED = TRUE
5 OAUTH_CLIENT = CUSTOM
6 OAUTH_CLIENT_TYPE = 'CONFIDENTIAL'
7 OAUTH_REDIRECT_URI = 'http://localhost:8080'
8 OAUTH_ISSUE_REFRESH_TOKENS = TRUE
9 OAUTH_REFRESH_TOKEN_VALIDITY = 86400;
10
11-- Get client ID and secret
12DESCRIBE SECURITY INTEGRATION dbt_oauth;
While creating the OAuth app in Snowflake, pay attention to the redirect_uri and the token_ validity parameters above. Redirect URI depends on the provider you are using. For example, in Paradime, you can find the redirect URIs at in our Configure Snowflake OAuth section of the help docs.
Get the client ID and secret in the previous step as follows:
1my_snowflake_profile:
2 target: dev
3 outputs:
4 dev:
5 type: snowflake
6 account: your_account.region
7 authenticator: oauth
8 oauth_client_id: your_oauth_client_id
9 oauth_client_secret: your_oauth_client_secret
10 role: your_role
11 database: your_database
12 warehouse: your_warehouse
13 schema: your_schema
14 threads: 4
In Paradime, this process is significantly faster. Once an OAuth app is created, an admin on Paradime can create the connection and every additional user just needs to authenticate from Paradime on their Snowflake. The biggest benefit of this approach is that users can use Paradime and SSO + MFA on their Snowflake all together. See how to setup Snowflake using OAuth with Paradime.
1openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
This command does two things:
- Generates a 2048-bit RSA key
- Converts it to PKCS8 format, which Snowflake requires
1openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
This extracts the public key from your private key file.
1awk '{printf "%s\\n", $0}' rsa_key.pub | pbcopy
This command formats the public key as a single line with '\n' for newlines, and copies it to your clipboard.
1ALTER USER your_username SET RSA_PUBLIC_KEY='[paste your public key here]';
1my_snowflake_profile:
2 target: dev
3 outputs:
4 dev:
5 type: snowflake
6 account: your_account
7 user: your_username
8 private_key_path: /path/to/rsa_key.p8
9 ...
Key points to remember:
- Keep your private key (rsa_key.p8) secure and never share it
- The public key (rsa_key.pub) is safe to share with Snowflake
- Use a strong passphrase if you choose to encrypt the private key
- Store the private key path securely, preferably as an environment variable
Remember to handle these keys with care. The private key grants access to your Snowflake account, so treat it like a password.
Keeping private key stored in local laptops defeats the purpose of enhanced security. On Paradime, we make this process much more secure by generating the profiles.yaml and keeping it away from user access. See how to setup Snowflake and Key-Pair authentication on Paradime.
1. Always use environment variables for sensitive info.
2. Rotate credentials regularly.
3. Use the least privileged role necessary for your dbt™ tasks.
4. Test your connection with `dbt debug` before running models.
Let's break down the security considerations for each connection method as follows:
Each connection method has its strengths and potential vulnerabilities, so choose the one that best aligns with your security requirements and operational needs.
There you have it! Three killer ways to connect dbt™ to Snowflake. Choose the method that fits your security needs and development workflow. Remember, a solid connection is the foundation of smooth dbt™ operations. Now go forth and transform that data like a boss!
Paradime's got your back for everything dbt™ and Snowflake. Here's why we're crushing it:
How are we doing it?
Ready to leave dbt Cloud™ in the dust? Hit us up for a chat.
Let's skyrocket your analytics game together! 🚀 🙌