> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squasher.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Terraform provider

> Manage Squasher resources with Terraform.

# Terraform provider

The Squasher Terraform provider manages monitors, status pages, notification routing, dashboards, and on-call configuration through the public API. It also exposes project, monitor, and dashboard template data sources.

## Install from source

Build the provider with Go and place the binary in your Terraform plugin directory:

```sh theme={null}
go build ./cmd/terraform-provider-squasher
```

## Configure

Set `SQUASHER_API_KEY` to a project API key, and set the project:

```hcl theme={null}
provider "squasher" {
  project_id = var.project_id # or SQUASHER_PROJECT_ID
}
```

`api_url` defaults to `https://api.squasher.ai`. `api_key` defaults to `SQUASHER_API_KEY`.

## Resources

| Resource | Import ID | Notes |
| - | - | - |
| `squasher_monitor` | `<monitor_id>` | `config` holds the check settings for the monitor `kind`. Query monitors are not supported yet. |
| `squasher_status_page` | `<status_page_id>` | `slug` is unique across Squasher. |
| `squasher_status_page_component` | `<status_page_id>/<component_id>` | |
| `squasher_status_page_monitor_link` | `<status_page_id>/<component_id>` | Leave `type` and `monitor_id` unset on the component, because the link sets them. |
| `squasher_notification_destination` | `<destination_id>` | Destinations cannot be edited, so every change replaces the destination. |
| `squasher_notification_route` | `<route_id>` | Only `destination_ids` changes in place. Other changes replace the route. |
| `squasher_dashboard` | `<dashboard_id>` | Manage widgets in the dashboard or through the API. |
| `squasher_on_call_rotation` | `<rotation_id>` | Only `enabled` changes in place. Destroy fails while an escalation policy outside Terraform targets the rotation. |
| `squasher_escalation_policy` | `<policy_id>` | `levels` is a JSON array in the API's snake\_case shape. |

```hcl theme={null}
resource "squasher_monitor" "api" {
  name   = "api-health"
  kind   = "http"
  target = "https://example.com/health"
  config = {
    method                = "GET"
    timeout_ms            = 5000
    interval_minutes      = 5
    failure_threshold     = 2
    recovery_threshold    = 1
    expected_status_codes = [200]
  }
}

resource "squasher_notification_destination" "ops" {
  type  = "webhook"
  label = "Ops webhook"
  config = {
    url    = var.webhook_url
    secret = var.webhook_secret
  }
}

resource "squasher_notification_route" "api" {
  name            = "API incidents"
  scope           = { monitor_ids = [squasher_monitor.api.id] }
  conditions      = { events = ["opened", "resolved"] }
  destination_ids = [squasher_notification_destination.ops.id]
}

resource "squasher_escalation_policy" "primary" {
  name = "Primary"
  levels = jsonencode([{
    targets = [{ type = "user", user_id = var.user_id }]
    steps   = [{ channel = "sms", repeat = 1, wait_seconds = 60 }]
  }])
}
```

## Secrets and import

Webhook URLs, webhook secrets, and PagerDuty integration keys are sensitive and are never read back from the API. After you import a destination, Terraform plans to replace it unless the state already holds those values. Import every other resource with the ID in the table; the next plan is empty when the configuration matches.

## Data sources

```hcl theme={null}
data "squasher_project" "current" {}

data "squasher_monitor" "api" {
  name = "api-health" # or id
}

data "squasher_dashboard_template" "errors" {
  name = "Error overview" # or id
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.