Terraform module for Snowflake stage management.
- Creates Snowflake stage
- Can create custom Snowflake database-roles with role-to-role assignments
- Can create a set of default roles to simplify access management:
READONLY
- grantedUSAGE
orREAD
privilagesREADWRITE
- grantedWRITE
privilegesADMIN
- grantedALL PRIVILEGES
module "snowflake_stage" {
source = "getindata/stage/snowflake"
# version = "x.x.x"
name = "my_stage"
schema = "my_schema"
database = "my_db"
url = "s3://com.example.bucket/prefix"
credentials = "AWS_KEY_ID='${var.example_aws_key_id}' AWS_SECRET_KEY='${var.example_aws_secret_key}'"
create_default_database_roles = true
}
Due to breaking changes in Snowflake provider and additional code optimizations, breaking changes were introduced in v2.0.0
version of this module.
List of code and variable (API) changes:
-
Switched to
snowflake_grant_ownership
resource instead of provider-removedsnowflake_role_ownership_grant
-
Switched to
snowflake_database_role
module to leverage newdatabase_roles
mechanism -
default_roles
andcustom_roles
are now combined and managed by single module -
roles
variable map received following additions:all_privileges
- optional, boolon_all
- optional, bool, defaults to falseon_future
- optional, bool, defaults to falsewith_grant_option
- optional, boolgranted_to_database_roles
- optional, stringgranted_database_roles
- optional, list of strings
-
and got following items removed:
enabled
comment
role_ownership_grant
granted_roles
granted_to_users
When upgrading from v1.x
, expect most of the resources to be recreated - if recreation is impossible, then it is possible to import some existing resources.
For more information, refer to variables.tf, list of inputs below and Snowflake provider documentation
Due to replacement of nulllabel (context.tf
) with context provider, some breaking changes were introduced in v3.0.0
version of this module.
List od code and variable (API) changes:
- Removed
context.tf
file (a single-file module with additonal variables), which implied a removal of all its variables (exceptname
):descriptor_formats
label_value_case
label_key_case
id_length_limit
regex_replace_chars
label_order
additional_tag_map
tags
labels_as_tags
attributes
delimiter
stage
environment
tenant
namespace
enabled
context
- Remove support
enabled
flag - that might cause some backward compatibility issues with terraform state (please take into account that propermove
clauses were added to minimize the impact), but proceed with caution - Additional
context
provider configuration - New variables were added, to allow naming configuration via
context
provider:context_templates
name_schema
Name | Description | Type | Default | Required |
---|---|---|---|---|
aws_external_id | ID of the customer AWS account | string |
null |
no |
comment | Specifies a comment for the stage | string |
null |
no |
context_templates | Map of context templates used for naming conventions - this variable supersedes naming_scheme.properties and naming_scheme.delimiter configuration |
map(string) |
{} |
no |
copy_options | Specifies the copy options for the stage | string |
null |
no |
create_default_roles | Whether the default database roles should be created | bool |
false |
no |
credentials | Specifies the credentials for the stage | string |
null |
no |
database | The database in which to create the stage | string |
n/a | yes |
directory | Specifies the directory settings for the stage | string |
null |
no |
encryption | Specifies the encryption settings for the stage | string |
null |
no |
file_format | Specifies the file format for the stage | string |
null |
no |
name | Name of the resource | string |
n/a | yes |
name_scheme | Naming scheme configuration for the resource. This configuration is used to generate names using context provider: - properties - list of properties to use when creating the name - is superseded by var.context_templates - delimiter - delimited used to create the name from properties - is superseded by var.context_templates - context_template_name - name of the context template used to create the name- replace_chars_regex - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name- extra_values - map of extra label-value pairs, used to create a name |
object({ |
{} |
no |
roles | Database roles created in the stage scope | map(object({ |
{} |
no |
schema | The schema in which to create the stage | string |
n/a | yes |
snowflake_iam_user | Specifies the Snowflake IAM user | string |
null |
no |
stage_ownership_grant | To which account role the stage ownership should be granted | string |
null |
no |
storage_integration | Specifies the name of the storage integration used to delegate authentication responsibility for external cloud storage to a Snowflake identity and access management (IAM) entity | string |
null |
no |
url | Specifies the URL for the stage | string |
null |
no |
Name | Source | Version |
---|---|---|
roles_deep_merge | Invicton-Labs/deepmerge/null | 0.1.5 |
snowflake_custom_role | getindata/database-role/snowflake | 2.0.1 |
snowflake_default_role | getindata/database-role/snowflake | 2.0.1 |
Name | Description |
---|---|
database_roles | This stage access roles |
fully_qualified_name | Fully Qualified Name of the stage |
name | Name of the stage |
Name | Version |
---|---|
context | >=0.4.0 |
snowflake | >= 0.95 |
Name | Version |
---|---|
terraform | >= 1.3 |
context | >=0.4.0 |
snowflake | >= 0.95 |
Name | Type |
---|---|
snowflake_grant_ownership.stage_ownership | resource |
snowflake_stage.this | resource |
context_label.this | data source |
Contributions are very welcomed!
Start by reviewing contribution guide and our code of conduct. After that, start coding and ship your changes by creating a new PR.
Apache 2 Licensed. See LICENSE for full details.
Made with contrib.rocks.