Skip to content

Terraform Provider Reference

The OpenStatus Terraform provider enables you to manage your OpenStatus monitors and status pages programmatically using HashiCorp Terraform. This allows for Infrastructure as Code (IaC) practices, version control, and automated deployment of your monitoring configurations.

Key capabilities:

  • Define and manage OpenStatus monitors as Terraform resources.
  • Automate the deployment and updates of monitoring configurations.
  • Integrate OpenStatus into your existing IaC workflows.

To use the OpenStatus Terraform provider, declare it in your Terraform configuration file (.tf). Terraform will automatically download and install the provider when you run terraform init.

terraform {
required_providers {
openstatus = {
source = "openstatusHQ/openstatus"
version = "~> 0.1" # Use the latest version
}
}
}

For the latest provider version, refer to the official Terraform Registry.

The OpenStatus Terraform provider requires authentication via an API token.

Type: String (required) Description: Your OpenStatus API Access Token. This token is used to authenticate your Terraform requests with the OpenStatus API.

Example:

provider "openstatus" {
openstatus_api_token = "YOUR_OPENSTATUS_API_TOKEN"
}

The provider currently supports managing openstatus_monitor resources.

Manages an OpenStatus monitor. This resource allows you to define and control the parameters of a synthetic monitor.

Arguments:

ArgumentTypeRequiredDefaultDescription
urlstringYesThe URL or URI of the endpoint to be monitored. Format depends on the monitor type (e.g., full URL for HTTP, host:port for TCP).
regionslist(string)YesA list of region identifiers (e.g., "iad", "jnb") from where the monitor checks will be performed.
periodicitystringYesThe frequency at which the monitor will perform checks. Supported values: "30s", "1m", "5m", "10m", "30m", "1h".
namestringYesA human-readable name for the monitor.
activeboolYesSpecifies whether the monitor is active (true) or paused (false).
descriptionstring (optional)No""A detailed description of the monitor’s purpose or configuration.
monitor_typestringYesThe type of monitor to create. Supported values: "HTTP", "TCP", "DNS"
methodstring (optional)No"GET"(HTTP monitors only) The HTTP method to use for the request (e.g., "GET", "POST").
bodystring (optional)No""(HTTP monitors only) The request body to send for POST, PUT, PATCH methods.
headersmap(string) (optional)No{}(HTTP monitors only) A map of custom HTTP headers to include with the request.
timeoutstring (optional)No"45s"The maximum duration to wait for a response. Format: duration string (e.g., "30s", "1m").
degraded_afterstring (optional)No""The duration after which a response is considered degraded. Format: duration string.
retriesnumber (optional)No3The number of times the monitor will retry a failed check.
publicbool (optional)NofalseControls whether monitor data is accessible on your public status page.
otlp_endpointstring (optional)No""The OTLP (OpenTelemetry Protocol) endpoint URL for exporting metrics.
otlp_headersmap(string) (optional)No{}Custom headers to include when exporting metrics to your OTLP endpoint.

Example Usage:

resource "openstatus_monitor" "my_website_monitor" {
name = "My Website Availability"
description = "Checks the main website for uptime and response time."
url = "https://www.example.com"
monitor_type = "HTTP"
method = "GET"
regions = ["us-east-1", "eu-west-1"]
periodicity = "1m"
active = true
public = true
timeout = "60s"
}
resource "openstatus_monitor" "internal_api_monitor" {
name = "Internal API Health Check"
description = "Monitors the health of a critical internal API."
url = "https://api.internal.corp:8443/health"
monitor_type = "HTTP"
method = "GET"
regions = ["private-location-id"]
periodicity = "5m"
active = true
public = false
headers = {
"Authorization" = "Bearer ${var.internal_api_token}"
"Accept" = "application/json"
}
}
resource "openstatus_monitor" "database_port_monitor" {
name = "Database TCP Port Check"
description = "Ensures the PostgreSQL port is open and reachable."
url = "db.example.com:5432"
monitor_type = "TCP"
regions = ["us-west-2"]
periodicity = "30s"
active = true
}