Skip to content

Latest commit

 

History

History

Complete Example

module "snowflake_shared_database" {
  source = "../.."

  name       = "SHARED_DATABASE"
  context    = module.this.context
  from_share = var.from_share

  descriptor_name            = "snowflake-database"
  comment                    = "Sample shared Database"
  replace_invalid_characters = true
  default_ddl_collation      = "UTF8"
  log_level                  = "INFO"
  trace_level                = "ON_EVENT"

  suspend_task_after_num_failures               = 1
  task_auto_retry_attempts                      = 1
  user_task_managed_initial_warehouse_size      = "X-Small"
  user_task_minimum_trigger_interval_in_seconds = 300
  user_task_timeout_ms                          = 200
  quoted_identifiers_ignore_case                = true
  enable_console_output                         = true

  create_default_roles = true

  roles = {
    readonly = {
      comment          = "Read-only role"
      granted_roles    = [resource.snowflake_account_role.this.name]
      granted_to_users = [resource.snowflake_user.this.name]
    }
  }
}

Usage

  1. Configure private sharing on producer Snowflake Account (remember that both producer and consumer accounts have to be deployed on the same Cloud Provider for. ex. AWS and in the same region for. ex. eu-west-1)

This step can be done manually using Snowsight UI or by running create_share.sql script on producer Snowflake account.

When using the script, please remember to properly define consumer account details in the last line:

ALTER SHARE sample_share ADD ACCOUNT="<orgname.accountname>";
  1. With share configured in step 1., run terraform on consumer account using below commands
terraform init
terraform plan -var-file fixtures.tfvars -out tfplan
terraform apply tfplan

Please remember to pass share details (from step 1.) to from_share variable.

$ terraform plan
var.from_share
  A fully qualified path to a share from which the database will be created. A fully qualified path follows the format of `<organization_name>.<account_name>.<share_name>`

  Enter a value: <orgname.accountname.sharename>

Inputs

Name Description Type Default Required
context_templates A map of context templates used to generate names map(string) n/a yes
from_share A fully qualified path to a share from which the database will be created. A fully qualified path follows the format of <organization_name>.<account_name>.<share_name> string n/a yes

Modules

Name Source Version
snowflake_shared_database ../.. n/a

Outputs

Name Description
example_output Example output of the module

Providers

Name Version
snowflake >= 0.94.0

Requirements

Name Version
terraform >= 1.3
context >=0.4.0
snowflake >= 0.94.0

Resources

Name Type
snowflake_account_role.this resource
snowflake_user.this resource