Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.devhelm.io/llms.txt

Use this file to discover all available pages before exploring further.

Get your first DevHelm monitor running with Terraform in 5 minutes.

Prerequisites

  • Terraform 1.5 or later
  • A DevHelm API token — create one from Settings → API Keys in the Dashboard
Set your token as an environment variable so the provider picks it up automatically:
export DEVHELM_API_TOKEN=dh_live_xxxxxxxx

1. Configure the provider

Create a main.tf file:
terraform {
  required_version = ">= 1.5.0"
  required_providers {
    devhelm = {
      source  = "devhelmhq/devhelm"
      version = "0.2.0-beta.4"
    }
  }
}

provider "devhelm" {}
Initialize the working directory:
terraform init
The provider reads DEVHELM_API_TOKEN from the environment. You can also set token directly in the provider block, but environment variables keep secrets out of your HCL files.

2. Create a monitor

Add an HTTP monitor resource to your main.tf:
resource "devhelm_monitor" "api_health" {
  name              = "API Health"
  type              = "HTTP"
  frequency_seconds = 60
  regions           = ["us-east", "eu-west"]

  config = jsonencode({
    url       = "https://api.example.com/health"
    method    = "GET"
    verifyTls = true
  })

  assertions {
    type   = "status_code"
    config = jsonencode({ expected = "200", operator = "equals" })
  }

  assertions {
    type     = "response_time"
    config   = jsonencode({ thresholdMs = 2000 })
    severity = "warn"
  }
}
config and assertions[].config are JSON strings, not HCL blocks. Use jsonencode({...}) with camelCase field names — they map directly to the API wire format.

3. Plan and apply

Preview what Terraform will create:
terraform plan
You should see one resource to add. Apply it:
terraform apply
Type yes to confirm. Your monitor is now live and checking every 60 seconds.

4. Add an alert channel

Wire up Slack (or any other channel) so you get notified when things break:
resource "devhelm_alert_channel" "slack" {
  name         = "Engineering Slack"
  channel_type = "slack"
  webhook_url  = var.slack_webhook_url
}

variable "slack_webhook_url" {
  type      = string
  sensitive = true
}
Link the alert channel to your monitor:
resource "devhelm_monitor" "api_health" {
  # ... same config as above ...

  alert_channel_ids = [devhelm_alert_channel.slack.id]
}
Run terraform apply again — the monitor now routes failures to your Slack channel.

5. Organize with tags

resource "devhelm_tag" "production" {
  name  = "production"
  color = "#10b981"
}

resource "devhelm_monitor" "api_health" {
  # ... same config as above ...

  tag_ids = [devhelm_tag.production.id]
}

Import existing resources

Already have monitors in the dashboard? Import them into Terraform state by name:
terraform import devhelm_monitor.api_health "API Health"
terraform import devhelm_alert_channel.slack "Engineering Slack"
See Importing resources for the full ID table.

Next steps

Provider overview

Full provider reference with all resources and data sources.

Monitor resource

Complete devhelm_monitor attribute reference.

Alert channels

Channel-type-specific Terraform arguments.

Terraform in CI/CD

Automate plans and applies in GitHub Actions or other CI systems.