A Terraform module for creating and managing Snowflake warehouses using a map of configuration objects. Supports creating single or multiple warehouses with a single module call.
- Map-based configuration for creating single or multiple warehouses
- Built-in input validation with descriptive error messages
- Sensible defaults for optional properties
- Outputs keyed by warehouse identifier for easy reference
- Support for all Snowflake warehouse sizes and configurations
module "warehouse" {
source = "github.com/subhamay-bhattacharyya-tf/terraform-snowflake-module-template"
warehouse_configs = {
"my_warehouse" = {
name = "MY_WAREHOUSE"
warehouse_size = "X-SMALL"
warehouse_type = "STANDARD"
auto_resume = true
auto_suspend = 60
initially_suspended = true
min_cluster_count = 1
max_cluster_count = 1
scaling_policy = "STANDARD"
enable_query_acceleration = false
comment = "My test warehouse"
}
}
}locals {
warehouses = {
"adhoc_wh" = {
name = "SN_TEST_ADHOC_WH"
warehouse_size = "X-SMALL"
warehouse_type = "STANDARD"
auto_resume = true
auto_suspend = 60
initially_suspended = true
min_cluster_count = 1
max_cluster_count = 1
scaling_policy = "STANDARD"
enable_query_acceleration = false
comment = "Development and sandbox warehouse for ad-hoc queries"
}
"load_wh" = {
name = "SN_TEST_LOAD_WH"
warehouse_size = "X-SMALL"
warehouse_type = "STANDARD"
auto_resume = true
auto_suspend = 60
initially_suspended = true
min_cluster_count = 1
max_cluster_count = 1
scaling_policy = "STANDARD"
enable_query_acceleration = false
comment = "Dedicated ingestion warehouse for loading files"
}
"transform_wh" = {
name = "SN_TEST_TRANSFORM_WH"
warehouse_size = "MEDIUM"
warehouse_type = "STANDARD"
auto_resume = true
auto_suspend = 300
initially_suspended = true
min_cluster_count = 1
max_cluster_count = 3
scaling_policy = "STANDARD"
enable_query_acceleration = true
comment = "ETL/ELT warehouse for transformations"
}
}
}
module "warehouses" {
source = "github.com/subhamay-bhattacharyya-tf/terraform-snowflake-module-template"
warehouse_configs = local.warehouses
}- Basic (Single Warehouse) - Create a single warehouse
- Multiple Warehouses - Create multiple warehouses
| Name | Version |
|---|---|
| terraform | >= 1.3.0 |
| snowflake | >= 0.87.0 |
| Name | Source | Version |
|---|---|---|
| snowflake | snowflakedb/snowflake | >= 0.87.0 |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| warehouse_configs | Map of configuration objects for Snowflake warehouses | map(object) |
{} |
no |
| Property | Type | Default | Description |
|---|---|---|---|
| name | string | - | Warehouse identifier (required) |
| warehouse_size | string | "X-SMALL" | Size of the warehouse |
| warehouse_type | string | "STANDARD" | Type of warehouse (STANDARD, SNOWPARK-OPTIMIZED) |
| auto_resume | bool | true | Auto-resume when queries are submitted |
| auto_suspend | number | 60 | Seconds of inactivity before auto-suspend |
| initially_suspended | bool | true | Start in suspended state |
| min_cluster_count | number | 1 | Minimum number of clusters |
| max_cluster_count | number | 1 | Maximum number of clusters |
| scaling_policy | string | "STANDARD" | Scaling policy (STANDARD, ECONOMY) |
| enable_query_acceleration | bool | false | Enable query acceleration |
| comment | string | null | Description of the warehouse |
- X-SMALL (XSMALL)
- SMALL
- MEDIUM
- LARGE
- X-LARGE (XLARGE)
- 2X-LARGE (XXLARGE, X2LARGE)
- 3X-LARGE (XXXLARGE, X3LARGE)
- 4X-LARGE (X4LARGE)
- 5X-LARGE (X5LARGE)
- 6X-LARGE (X6LARGE)
- STANDARD
- SNOWPARK-OPTIMIZED
- STANDARD
- ECONOMY
| Name | Description |
|---|---|
| warehouse_names | Map of warehouse names keyed by identifier |
| warehouse_fully_qualified_names | Map of fully qualified warehouse names |
| warehouse_sizes | Map of warehouse sizes |
| warehouse_states | Map of warehouse states (STARTED or SUSPENDED) |
| warehouses | All warehouse resources |
The module validates inputs and provides descriptive error messages for:
- Empty warehouse name
- Invalid warehouse size
- Invalid warehouse type
- Invalid scaling policy
- Negative auto_suspend value
- min_cluster_count exceeding max_cluster_count
The module includes Terratest-based integration tests:
cd test
go mod tidy
go test -v -timeout 30mRequired environment variables for testing:
SNOWFLAKE_ORGANIZATION_NAME- Snowflake organization nameSNOWFLAKE_ACCOUNT_NAME- Snowflake account nameSNOWFLAKE_USER- Snowflake usernameSNOWFLAKE_ROLE- Snowflake role (e.g., "SYSADMIN")SNOWFLAKE_PRIVATE_KEY- Snowflake private key for key-pair authentication
The CI workflow runs on:
- Push to
main,feature/**, andbug/**branches (when*.tf,examples/**, ortest/**changes) - Pull requests to
main(when*.tf,examples/**, ortest/**changes) - Manual workflow dispatch
The workflow includes:
- Terraform validation and format checking
- Examples validation
- Terratest integration tests (output displayed in GitHub Step Summary)
- Changelog generation (non-main branches)
- Semantic release (main branch only)
The CI workflow uses the following GitHub organization variables:
| Variable | Description | Default |
|---|---|---|
TERRAFORM_VERSION |
Terraform version for CI jobs | 1.3.0 |
GO_VERSION |
Go version for Terratest | 1.21 |
SNOWFLAKE_ORGANIZATION_NAME |
Snowflake organization name | - |
SNOWFLAKE_ACCOUNT_NAME |
Snowflake account name | - |
SNOWFLAKE_USER |
Snowflake username | - |
SNOWFLAKE_ROLE |
Snowflake role (e.g., SYSADMIN) | - |
The following GitHub secrets are required for Terratest integration tests:
| Secret | Description | Required |
|---|---|---|
SNOWFLAKE_PRIVATE_KEY |
Snowflake private key for key-pair authentication | Yes |
MIT License - See LICENSE for details.