Back to changelog
New
3 minute read

Snowflake: Warehouses and Resource Monitors

Atlas now supports Snowflake warehouses and resource monitors as first-class resources. Define your compute and its spending limits in HCL alongside your tables, and Atlas plans the CREATE, ALTER, and DROP statements for you.

Atlas now supports Snowflake warehouses and resource monitors as first-class resources. A warehouse is the compute that runs your queries, and a resource monitor caps the credits that compute can consume. You can now define both in HCL alongside your tables, and Atlas inspects, diffs, and migrates them declaratively.

Enabling the Feature

Warehouses and resource monitors are account-level objects, so Atlas only manages them when you opt in. Enable them with warehouses = true and resource_monitors = true inside the mode "snowflake" block of your env:

env "prod" {
url = "snowflake://user:pass@account_identifier/database"
dev = "snowflake://user:pass@dev_account_identifier/database"
schema {
src = "file://schema.hcl"
mode "snowflake" {
warehouses = true
resource_monitors = true
}
}
}

Defining a Resource Monitor

The resource_monitor block sets a credit budget and the actions Atlas takes as usage climbs. The example below allows 1000 credits a month, notifies alice and bob at 80% usage, and suspends the warehouse once it reaches 100%:

resource_monitor "analytics_rm" {
credit_quota = 1000
frequency = MONTHLY
notify_users = ["alice", "bob"]
trigger {
threshold = 80
action = NOTIFY
}
trigger {
threshold = 100
action = SUSPEND
}
}

Each trigger fires an action when usage reaches a threshold percentage of the quota: NOTIFY sends an alert, SUSPEND stops the warehouse after running queries finish, and SUSPEND_IMMEDIATE stops it right away.

Required role: In Snowflake, resource monitors can only be created and owned by the ACCOUNTADMIN role. Apply them with a connection that uses ACCOUNTADMIN (or a role it has granted the necessary privileges to), otherwise the CREATE RESOURCE MONITOR statement is rejected.

Defining a Warehouse

The warehouse block describes the compute that runs your queries. Common attributes are size, auto_suspend (seconds of inactivity before it pauses to save credits), auto_resume (wake up on the next query), and comment:

warehouse "analytics_wh" {
size = XSMALL
type = STANDARD
auto_suspend = 300
auto_resume = true
resource_monitor = resource_monitor.analytics_rm
comment = "Analytics workloads"
}

The resource_monitor attribute attaches a spending limit to the warehouse. Reference a monitor you defined with resource_monitor.analytics_rm and Atlas creates the monitor before the warehouse that points at it.

Required grant: Creating a warehouse needs the CREATE WAREHOUSE privilege on the account, which the SYSADMIN role holds by default. Attaching a resource monitor is an account-level action, so a warehouse that sets resource_monitor must be applied with the ACCOUNTADMIN role.

Generated SQL

Atlas plans the right statements from the diff between your desired and current state. The first apply creates the monitor, then the warehouse:

-- Create resource monitor "analytics_rm"
CREATE RESOURCE MONITOR "analytics_rm" WITH CREDIT_QUOTA = 1000 FREQUENCY = MONTHLY NOTIFY_USERS = (alice, bob) TRIGGERS ON 80 PERCENT DO NOTIFY ON 100 PERCENT DO SUSPEND;
-- Create warehouse "analytics_wh"
CREATE WAREHOUSE "analytics_wh" WAREHOUSE_TYPE = 'STANDARD' WAREHOUSE_SIZE = 'X-Small' AUTO_SUSPEND = 300 AUTO_RESUME = TRUE RESOURCE_MONITOR = analytics_rm COMMENT = 'Analytics workloads';

Later changes, such as resizing the warehouse or adding a trigger, are applied in place with ALTER WAREHOUSE SET and ALTER RESOURCE MONITOR SET instead of recreating anything:

-- Resize the warehouse
ALTER WAREHOUSE "analytics_wh" SET WAREHOUSE_SIZE = 'LARGE';
-- Add a notify trigger to the resource monitor
ALTER RESOURCE MONITOR "analytics_rm" SET TRIGGERS ON 80 PERCENT DO NOTIFY ON 100 PERCENT DO SUSPEND;

For the complete attribute reference, see the warehouse and resource_monitor HCL documentation.

featuresnowflakewarehouseresource-monitor