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 = trueresource_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 = 1000frequency = MONTHLYnotify_users = ["alice", "bob"]trigger {threshold = 80action = NOTIFY}trigger {threshold = 100action = 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.
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 = XSMALLtype = STANDARDauto_suspend = 300auto_resume = trueresource_monitor = resource_monitor.analytics_rmcomment = "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.
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 warehouseALTER WAREHOUSE "analytics_wh" SET WAREHOUSE_SIZE = 'LARGE';-- Add a notify trigger to the resource monitorALTER 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.