A Terraform module for importing Snowflake shares as databases and granting access privileges to account roles.
This module simplifies the process of:
- Importing external Snowflake shares as databases in your account
- Automatically granting
IMPORTED PRIVILEGESto specified account roles - Managing multiple shares and role grants through a single configuration
- Terraform >= 1.0
- Snowflake provider >= 2.1.0, < 3.0.0
- Access to Snowflake with appropriate privileges (SYSADMIN role)
- Approved access to the shares you want to import
module "snowflake_shared_databases" {
source = "github.com/inovex/snowflake-import-listing.git?ref=0.0.2"
providers = {
snowflake.sysadmin = snowflake.sysadmin
}
snowflake_shares = [
{
database_name = "IMPORTED_DB_NAME"
share_name = "YOUR_ORG.SOME_ACCOUNT.SHARE_NAME"
},
]
account_roles = [
"ANALYST_ROLE",
"DATA_ENGINEER_ROLE",
]
}module "snowflake_shared_databases" {
source = "github.com/inovex/snowflake-import-listing.git?ref=0.0.2"
providers = {
snowflake.sysadmin = snowflake.sysadmin
}
snowflake_shares = [
{
database_name = "CUSTOMER_DATA_SHARE"
share_name = "PROVIDER_ORG.PROVIDER_ACCOUNT.CUSTOMER_SHARE"
},
{
database_name = "PRODUCT_DATA_SHARE"
share_name = "PROVIDER_ORG.PROVIDER_ACCOUNT.PRODUCT_SHARE"
},
]
account_roles = [
"ANALYST_ROLE",
"DATA_ENGINEER_ROLE",
"BI_DEVELOPER_ROLE",
]
}- Navigate to Data Products > Private Sharing in the Snowflake Web UI
- Search for the relevant listing
- Click the Request button to request access
- Go to Data Products > Private Sharing > Requests > Outbound
- Monitor the status of your request
- Wait for the status to change to Approved
Once approved, execute the following SQL query in a Snowflake worksheet:
SHOW SHARES;The full share name is constructed by concatenating the owner_account and name columns:
<owner_account>.<name>
For example: ACME_ORG.XY12345.SALES_DATA_SHARE
Add the share to your module configuration:
snowflake_shares = [
{
database_name = "SALES_DATA" # Your desired database name
share_name = "ACME_ORG.XY12345.SALES_DATA_SHARE" # From SHOW SHARES
},
]| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| snowflake_shares | List of Snowflake shares to import as databases | list(object({ database_name = string, share_name = string })) |
Example values provided | yes |
| account_roles | List of Snowflake account roles that will be granted IMPORTED PRIVILEGES | list(string) |
["EXAMPLE_ROLE_1"] |
yes |
| Name | Description |
|---|---|
| shared_databases | Map of imported shared databases with their configurations |
| database_names | List of imported database names |
| granted_privileges | Map of privilege grants to account roles |
- Database Import: For each share in
snowflake_shares, the module creates asnowflake_shared_databaseresource - Privilege Grants: The module creates a cartesian product of all shares and roles, then grants
IMPORTED PRIVILEGESon each database to each role - Access Control: Roles specified in
account_rolescan immediately query the imported databases
- At least one share must be specified
- At least one account role must be specified
- Database names must contain only uppercase letters, numbers, and underscores
- The module uses the
snowflake.sysadminprovider for all operations IMPORTED PRIVILEGESis the standard privilege for accessing shared databases- Changes to shares or roles will automatically update the privilege grants
- Database names should follow Snowflake naming conventions (uppercase with underscores)
See LICENSE file for details.