https://github.com/getindata/terraform-snowflake-warehouse
Terraform module for Snowflake Warehouse management
https://github.com/getindata/terraform-snowflake-warehouse
module snowflake snowflakedb terraform
Last synced: 6 months ago
JSON representation
Terraform module for Snowflake Warehouse management
- Host: GitHub
- URL: https://github.com/getindata/terraform-snowflake-warehouse
- Owner: getindata
- License: apache-2.0
- Created: 2022-11-29T14:13:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T18:52:30.000Z (8 months ago)
- Last Synced: 2025-04-09T20:11:21.455Z (6 months ago)
- Topics: module, snowflake, snowflakedb, terraform
- Language: HCL
- Homepage:
- Size: 85 KB
- Stars: 3
- Watchers: 6
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Terraform Snowflake Warehouse



![]()
We help companies turn their data into assets
---
Terraform module for Snowflake Warehouse management
- Creates Snowflake Warehouse
- Can create custom Snowflake Roles with role-to-role, role-to-user assignments
- Can create a set of default, functional roles to simplify access management:
- `ADMIN` - full access
- `MONITOR` - abillity to monitor warehouse
- `USAGE` - abillity to use warehouse## USAGE
```terraform
module "terraform_snowflake_warehouse" {
source = "getindata/warehouse/snowflake"
context = module.this.contextname = "warehouse"
comment = "My Warehouse"warehouse_size = "x-small"
auto_resume = true
auto_suspend = 600
initially_suspended = truecreate_default_roles = true
roles = {
admin = {
granted_to_roles = ["SYSADMIN"]
}
}
}```
## NOTES
When upgrading to version `v2.2.x` - all `default_roles` will be recreated using new terraform resources.
## EXAMPLES
- [Simple](examples/simple)
- [Complete](examples/complete)## Breaking changes in v3.x of the module
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 (except `name`):
- `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 proper `move` 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`## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [auto\_resume](#input\_auto\_resume) | Specifies whether to automatically resume a warehouse when a SQL statement (e.g. query) is submitted to it. | `bool` | `true` | no |
| [auto\_suspend](#input\_auto\_suspend) | Specifies the number of seconds of inactivity after which a warehouse is automatically suspended. | `number` | `null` | no |
| [comment](#input\_comment) | Warehouse comment/description. | `string` | `null` | no |
| [context\_templates](#input\_context\_templates) | Map of context templates used for naming conventions - this variable supersedes `naming_scheme.properties` and `naming_scheme.delimiter` configuration | `map(string)` | `{}` | no |
| [create\_default\_roles](#input\_create\_default\_roles) | Whether the default roles should be created | `bool` | `false` | no |
| [enable\_query\_acceleration](#input\_enable\_query\_acceleration) | Specifies whether to enable the query acceleration service for queries that rely on this warehouse for compute resources. | `bool` | `true` | no |
| [initially\_suspended](#input\_initially\_suspended) | Specifies whether the warehouse is created initially in the ‘Suspended’ state. | `bool` | `true` | no |
| [max\_cluster\_count](#input\_max\_cluster\_count) | Specifies the maximum number of server clusters for the warehouse. | `number` | `1` | no |
| [max\_concurrency\_level](#input\_max\_concurrency\_level) | Object parameter that specifies the concurrency level for SQL statements (i.e. queries and DML) executed by a warehouse. | `number` | `null` | no |
| [min\_cluster\_count](#input\_min\_cluster\_count) | Specifies the minimum number of server clusters for the warehouse (only applies to multi-cluster warehouses). | `number` | `1` | no |
| [name](#input\_name) | Name of the resource | `string` | n/a | yes |
| [name\_scheme](#input\_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
- `uppercase` - convert name to uppercase |object({| `{}` | no |
properties = optional(list(string), ["environment", "name"])
delimiter = optional(string, "_")
context_template_name = optional(string, "snowflake-warehouse")
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
extra_values = optional(map(string))
uppercase = optional(bool, true)
})
| [query\_acceleration\_max\_scale\_factor](#input\_query\_acceleration\_max\_scale\_factor) | Specifies the maximum scale factor for leasing compute resources for query acceleration. The scale factor is used as a multiplier based on warehouse size. | `number` | `null` | no |
| [resource\_monitor](#input\_resource\_monitor) | Specifies the name of a resource monitor that is explicitly assigned to the warehouse. | `string` | `null` | no |
| [roles](#input\_roles) | Account roles created on the warehouse level |map(object({| `{}` | no |
name_scheme = optional(object({
properties = optional(list(string))
delimiter = optional(string)
context_template_name = optional(string)
replace_chars_regex = optional(string)
extra_labels = optional(map(string))
uppercase = optional(bool)
}))
comment = optional(string)
role_ownership_grant = optional(string)
granted_roles = optional(list(string))
granted_to_roles = optional(list(string))
granted_to_users = optional(list(string))
warehouse_grants = optional(object({
all_privileges = optional(bool)
with_grant_option = optional(bool, false)
privileges = optional(list(string))
}))
}))
| [scaling\_policy](#input\_scaling\_policy) | Specifies the policy for automatically starting and shutting down clusters in a multi-cluster warehouse running in Auto-scale mode. Valid values are `STANDARD` and `ECONOMY`. | `string` | `null` | no |
| [statement\_queued\_timeout\_in\_seconds](#input\_statement\_queued\_timeout\_in\_seconds) | Object parameter that specifies the time, in seconds, a SQL statement (query, DDL, DML, etc.) can be queued on a warehouse before it is canceled by the system. | `number` | `null` | no |
| [statement\_timeout\_in\_seconds](#input\_statement\_timeout\_in\_seconds) | Specifies the time, in seconds, after which a running SQL statement (query, DDL, DML, etc.) is canceled by the system | `number` | `null` | no |
| [warehouse\_size](#input\_warehouse\_size) | Specifies the size of the virtual warehouse. Possible values are: XSMALL, X-SMALL, SMALL, MEDIUM, LARGE, XLARGE, X-LARGE, XXLARGE, X2LARGE, 2X-LARGE, XXXLARGE, X3LARGE, 3X-LARGE, X4LARGE, 4X-LARGE, X5LARGE, 5X-LARGE, X6LARGE, 6X-LARGE. | `string` | `"X-Small"` | no |
| [warehouse\_type](#input\_warehouse\_type) | Specifies the type of the virtual warehouse. | `string` | `"STANDARD"` | no |## Modules
| Name | Source | Version |
|------|--------|---------|
| [roles\_deep\_merge](#module\_roles\_deep\_merge) | Invicton-Labs/deepmerge/null | 0.1.5 |
| [snowflake\_custom\_role](#module\_snowflake\_custom\_role) | getindata/role/snowflake | 3.1.0 |
| [snowflake\_default\_role](#module\_snowflake\_default\_role) | getindata/role/snowflake | 3.1.0 |## Outputs
| Name | Description |
|------|-------------|
| [roles](#output\_roles) | Access roles created for warehouse |
| [warehouse](#output\_warehouse) | Details of the warehouse |## Providers
| Name | Version |
|------|---------|
| [context](#provider\_context) | >=0.4.0 |
| [snowflake](#provider\_snowflake) | >= 0.95 |## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.3 |
| [context](#requirement\_context) | >=0.4.0 |
| [snowflake](#requirement\_snowflake) | >= 0.95 |## Resources
| Name | Type |
|------|------|
| [snowflake_warehouse.this](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/warehouse) | resource |
| [context_label.this](https://registry.terraform.io/providers/cloudposse/context/latest/docs/data-sources/label) | data source |## CONTRIBUTING
Contributions are very welcomed!
Start by reviewing [contribution guide](CONTRIBUTING.md) and our [code of conduct](CODE_OF_CONDUCT.md). After that, start coding and ship your changes by creating a new PR.
## LICENSE
Apache 2 Licensed. See [LICENSE](LICENSE) for full details.
## AUTHORS
Made with [contrib.rocks](https://contrib.rocks).