Uptime/

Terraform Provider

The Uptime Terraform provider lets you manage your monitoring infrastructure as code. Define services, configure checks, and set up alerts — all declaratively in HCL.

Why Terraform?

  • Version control — track changes to your monitoring setup alongside application code
  • Reproducibility — spin up identical monitoring for staging, production, or new projects
  • Automation — integrate with CI/CD pipelines to keep monitoring in sync with deployments
  • Team collaboration — review monitoring changes in pull requests like any other code

Prerequisites

  • Terraform v1.0 or later
  • An Uptime account with an API token or project token

Quick Start

This example creates a service, adds an HTTP health check, and configures an alert for consecutive failures.

main.tfhcl
terraform {
  required_providers {
    uptime = {
      source = "registry.terraform.io/skunkworq/uptime"
    }
  }
}

provider "uptime" {
  host      = "https://uptime-prod-api-5bbjdhyfxa-ts.a.run.app"
  api_token = var.uptime_api_token
  org_id    = var.uptime_org_id
}

# Create a service
resource "uptime_service" "api" {
  name        = "API Server"
  url         = "https://api.example.com"
  description = "Main API gateway"
  is_public   = true
}

# Add an HTTP health check
resource "uptime_check" "api_health" {
  service_id       = uptime_service.api.id
  name             = "HTTP Health Check"
  type             = "uptime"
  interval_seconds = 60
  timeout_seconds  = 30

  uptime_config {
    method                = "GET"
    expected_status_codes = [200]
    verify_ssl            = true
  }
}

# Alert on consecutive failures
resource "uptime_alert" "api_down" {
  check_id       = uptime_check.api_health.id
  name           = "API Down"
  condition_type = "consecutive_failures"

  consecutive_failures_config {
    count = 3
  }

  channel {
    type   = "email"
    target = "ops@example.com"
  }
}

Project Tokens

For CI/CD pipelines, use project_token instead of api_token. Project tokens are scoped to a single organization and don't require org_id.

Resources

Next Steps