Skip to main content

Automate a Weekend Shutdown

Development and staging workspaces often run compute 24/7 that is only used during business hours. This tutorial sets up Kostavo to stop that compute automatically outside working hours, while guaranteeing it never touches anything while your team is working.

The setup has two halves:

  1. A profile in Fix mode that stops idle and running compute
  2. A schedule that blocks those actions during business hours

Key point: schedules block actions, not scans. Kostavo keeps detecting and recording findings around the clock. The schedule only decides when Fix and Remove are allowed to act. During business hours you get visibility; outside them you get enforcement.

Prerequisites

  • Admin or Owner role
  • At least one non-production workspace connected and assigned a profile

Step 1: Create a Cost Profile in Fix Mode

  1. Go to Policies and create a profile from the Cost Optimization template
  2. Name it, for example Off-hours cost sweep
  3. Set the key policies to Fix:
    • running_compute: terminate running clusters
    • warehouse_running: stop running SQL warehouses
    • cluster_no_autotermination: set an auto-termination threshold
  4. Save

The profile editor with cost policies and their action modes

Policies you leave in Notify mode still report, they just never act. Use that for anything you want to watch before automating. The full list of policies and what Fix does for each is in the policy catalog.

Step 2: Add Exceptions

Some compute legitimately runs around the clock. Exclude it now, before the first weekend:

  1. In the profile editor, open the exception list on running_compute
  2. Add the clusters that must survive: streaming ingest, 24/7 serving, shared infrastructure
  3. Save

If you skip this step, you will be doing it Monday morning instead.

Step 3: Create the Business Hours Schedule

  1. Go to Schedules and click New schedule

The schedules page with the New schedule button highlighted

  1. Pick the Block Business Hours template

The schedule template picker

  1. Adjust to your team's reality: days Monday through Friday, hours 08:00 to 18:00, your team's timezone
  2. Save

While this schedule is active, Fix and Remove are suppressed. Outside it (evenings and weekends), they run.

Date Overrides

Schedules support per-date exceptions:

  • Excluded dates: force the schedule inactive on a specific date. Use for company holidays, so cleanup runs even though it is a Tuesday.
  • Included dates: force it active. Use for that one Saturday the team is doing a release.

Step 4: Assign Profile and Schedule Together

  1. Go to PoliciesAssignments
  2. Create an assignment for each non-production workspace: the Off-hours cost sweep profile plus the business hours schedule
  3. Enable it

For many workspaces, skip the manual clicking and use a tag rule: match environment equals development or staging, assign this profile and schedule automatically. The tag automation guide shows that pattern.

Step 5: Check the Results Monday

After the first weekend, open MonitoringFindings and filter by your profile:

The findings list showing what the cost sweep acted on

Look at the Action taken column: FIXED entries are clusters and warehouses Kostavo stopped. The execution history on each finding shows exactly when.

Tuning

ObservationAdjustment
Something was stopped that should not have beenAdd it to the exception list
Users restart clusters and they get stopped againWorking as intended; a restarted cluster that goes idle again is stopped again
Nothing was stoppedConfirm the profile is in Fix mode, the assignment is enabled, and the schedule was not active all weekend