On Professional and Business, the Uptimecheck provider for Terraform, uptimecheck-com/uptimecheck in the Terraform Registry, manages monitors, projects, alert channels and status pages as code. It works through the REST API with an API key.
Create an API key
- Open Settings in the sidebar and choose the API tab.
- Choose New API key, name it after where it is used, such as “Terraform”, and pick Read & write. The provider creates and changes things, so a read-only key isn’t enough.
- Choose Create key and copy it. This is the only time the key is shown.
Add the provider
Add the provider to your configuration:
terraform {
required_providers {
uptimecheck = {
source = "uptimecheck-com/uptimecheck"
}
}
}
provider "uptimecheck" {}
Run terraform init, which downloads the provider from the Terraform Registry. Then put the key in the UPTIMECHECK_API_KEY environment variable, for example with export UPTIMECHECK_API_KEY=uc_your_api_key, or as a secret in your CI system. The provider also takes an api_key argument, but the environment variable keeps the key out of your files.
Add a monitor
resource "uptimecheck_monitor" "checkout" {
type = "http"
name = "Checkout"
target = "https://shop.example.com/checkout"
interval_seconds = 60
config = jsonencode({
expectedStatus = "200-299"
keyword = { value = "Add to cart", mode = "contains" }
slowMs = 1500
})
}
typeis one ofhttp,tcp,ping,dns,domain,heartbeat,server,vendor,crawlandflow. Changing it replaces the monitor.configholds the type’s settings as JSON, with the same keys as the API reference. Only the keys you write are managed, so the app’s defaults for the rest don’t show up as changes.interval_secondsis how often to check, from 60 to 3600 seconds (30 on a plan that allows it), 300 if you leave it out.channel_idspicks the alert channels,project_idthe project, andpaused = truepauses the monitor.
Run terraform plan to see what will change, then terraform apply. The monitor shows up in the app right away.
A cron job and its ping URL
resource "uptimecheck_monitor" "backup" {
type = "heartbeat"
name = "Nightly backup"
config = jsonencode({
schedule = { cron = "0 3 * * *", timeZone = "Europe/Stockholm" }
graceSeconds = 900
maxRunSeconds = 3600
})
}
output "backup_ping_url" {
value = uptimecheck_monitor.backup.heartbeat_url
sensitive = true
}
The ping URL is in heartbeat_url, marked sensitive. Read it with terraform output -raw backup_ping_url and add it to the job.
Projects, alert channels and status pages
uptimecheck_project: a project, such as a client, with anameand acolor. Deleting it leaves its monitors and status pages without a project; its client reports and client access are deleted with it.uptimecheck_alert_channel: email, Slack by incoming webhook, Microsoft Teams, Discord, Google Chat, Mattermost, PagerDuty, ntfy, Pushover and webhooks. The address or key goes inconfig, which the API never returns, so a change made in the app isn’t seen as drift.delay_minutes(5, 10, 15, 30 or 60) makes it an escalation step. A webhook’s signing secret is inwebhook_secret, returned only when the channel is created.uptimecheck_status_page: a status page with its title, look andcomponents, the monitors visitors see, in order and optionally grouped. Its password, email access list and custom CSS are set in the app and left alone. Deleting it deletes its subscribers, written updates and visitor statistics.- Data sources
uptimecheck_alert_channels,uptimecheck_projectsanduptimecheck_status_pageslist what exists. Use the first for SMS, Telegram, push and Add to Slack channels, which are set up in the app.
Bring in what you already have
Monitors, projects, alert channels and status pages made in the app can be imported by their ID:
terraform import uptimecheck_monitor.checkout mon_...
terraform import uptimecheck_project.acme prj_...
terraform import uptimecheck_alert_channel.slack ch_...
terraform import uptimecheck_status_page.public sp_...
An imported alert channel’s address and a webhook’s signing secret aren’t read back. Every resource and attribute is documented in the Terraform Registry. More on the Terraform integration, API keys and the REST API.