# Terraform / OpenTofu provider for Vigil Manage monitors, alert channels, status pages and server slots as code. Works with Terraform ≥ 1.5 and OpenTofu. ```hcl terraform { required_providers { vigil = { source = "puzaricloud.in/vigil/vigil" } } } provider "vigil" {} # VIGIL_API_KEY (+ VIGIL_ENDPOINT for self-hosted) from the environment resource "vigil_channel" "ops" { kind = "slack" name = "ops" config = { url = var.slack_webhook } } resource "vigil_monitor" "api" { name = "Checkout API" mode = "api" url = "https://api.example.com/health" interval_minutes = 1 expect_status = "200" assertions = "json status == ok" channel_ids = [vigil_channel.ops.id] slo_target = 99.9 } resource "vigil_monitor" "backup" { name = "nightly backup" mode = "heartbeat" schedule_cron = "0 3 * * *" grace_minutes = 30 channel_ids = [vigil_channel.ops.id] } output "backup_ping_url" { value = vigil_monitor.backup.ping_url } resource "vigil_server" "web" { name = "web-${count.index}" count = 3 tags = ["prod", "web"] rules_json = jsonencode({ cpu_pct = 90, disk_pct = 85, watch_services = ["nginx"] }) channel_ids = [vigil_channel.ops.id] } # cloud-init: the agent registers itself on first boot resource "hcloud_server" "web" { count = 3 user_data = "#!/bin/sh\n${vigil_server.web[count.index].install_command}\n" # ... } resource "vigil_status_page" "public" { title = "Example status" slug = "example" visibility = "public" monitor_ids = [vigil_monitor.api.id] groups_json = jsonencode([{ name = "APIs", monitor_ids = [vigil_monitor.api.id] }]) } ``` ## Install Binaries: https://puzaricloud.in/terraform (linux/darwin/windows, amd64/arm64). Put the binary in Terraform's filesystem mirror: mkdir -p ~/.terraform.d/plugins/puzaricloud.in/vigil/vigil/1.0.0/linux_amd64 curl -fsSL https://puzaricloud.in/terraform/terraform-provider-vigil_1.0.0_linux_amd64.zip -o p.zip && unzip p.zip -d ~/.terraform.d/plugins/puzaricloud.in/vigil/vigil/1.0.0/linux_amd64 terraform init Or build from source (Go 1.23+): `go build -o terraform-provider-vigil .` and use a `dev_overrides` block in `~/.terraformrc` pointing at the directory. ## Resources - `vigil_monitor` — every monitor type (`mode`): uptime, api, tcp, domain, keyword, text, price, health, heartbeat, flow (`steps_json`), dependency. `import` with the numeric id. - `vigil_channel` — `kind` + `config` map (same keys as the channel form: webhook `url`, slack/discord/teams `url`, telegram `chat_id`, email `to`, pagerduty `routing_key`, …). Data source `vigil_channel` looks up an existing channel by name. - `vigil_status_page` — components (`monitor_ids`), `groups_json`, `visibility` (members | password | public | hidden), custom domain, CSS. - `vigil_server` — a server slot; exports `token` and `install_command` (sensitive) for user-data. Plan limits apply exactly as in the UI (the API returns 402 with the reason). Out-of-band edits show up as drift on the next `plan`.