Terraform provider overview
Manage AlertOps as code with the official Terraform provider.
The AlertOps Terraform provider manages your AlertOps account as code: users, groups, on-call schedules, escalation policies, response plays, workflows, integrations, services, topics and maintenance windows. It is published on the Terraform Registry as alertopsofficial/alertops (version 2.1) and maintained by AlertOps.
Requirements
- Terraform 1.0 or later
- An AlertOps account with API access and a V2 API key (see Authentication)
Install the provider
terraform {
required_providers {
alertops = {
source = "alertopsofficial/alertops"
version = "~> 2.1"
}
}
}
provider "alertops" {
# Best practice: set via ALERTOPS_API_KEY environment variable
# api_key = "your-api-key"
}
Authentication
The provider requires an AlertOps API key. The following methods are supported, in order of precedence:
Environment variable (recommended)
export ALERTOPS_API_KEY="your-api-key"
terraform plan
Static credentials
provider "alertops" {
api_key = "your-api-key"
}
Warning: Hard-coding credentials in Terraform configuration is not recommended. Use the environment variable method or a secrets manager to keep credentials out of version control.
Schema
Optional
api_key(String, Sensitive) AlertOps API key. Can also be set via theALERTOPS_API_KEYenvironment variable.base_url(String) Base URL of the AlertOps v2 API. Defaults tohttps://api.alertops.com/api/v2. Can also be set viaALERTOPS_BASE_URL.requests_per_second(Number) Client-side request limit per second. Defaults to5. Can also be set viaALERTOPS_REQUESTS_PER_SECOND.requests_per_minute(Number) Client-side request limit per minute. Defaults to15. Can also be set viaALERTOPS_REQUESTS_PER_MINUTE.
Rate limiting
The AlertOps v2 API allows 5 requests per second and 15 per minute
per API key. The provider queues its requests to stay within these
limits and retries automatically (with backoff) if the API still answers
429 Too Many Requests, so large plans succeed but can take
several minutes. Raise requests_per_minute only if your
account has a higher limit.
Quick start
This configuration creates a user, an on-call group, a business-hours schedule, an escalation policy and an API inbound integration that routes to the group.
resource "alertops_user" "oncall" {
user_name = "jsmith"
first_name = "Jane"
last_name = "Smith"
locale = "en-US"
time_zone = "(UTC-05:00) Eastern Time (US & Canada)"
type = "Standard"
roles = ["App Admin"]
contact_methods = [
{
contact_method_name = "Email-Official"
email_address = "jsmith@example.com"
notification_time24x7 = true
enabled = true
sequence = 1
}
]
}
# Create an on-call group
resource "alertops_group" "ops_team" {
group_name = "ops-team"
members = [
{
member_type = "User"
member = alertops_user.oncall.user_name
sequence = 1
roles = ["Primary"]
}
]
}
# Create a schedule
resource "alertops_schedule" "business_hours" {
group = alertops_group.ops_team.group_name
schedule_name = "Business Hours"
schedule_type = "Fixed"
time_zone = "(UTC-05:00) Eastern Time (US & Canada)"
weekday_mon = true
weekday_tue = true
weekday_wed = true
weekday_thu = true
weekday_fri = true
weekday_sat = false
weekday_sun = false
}
# Create an escalation policy
resource "alertops_escalation_policy" "default" {
escalation_policy_name = "Default Policy"
priority = "High"
}
# Create an API inbound integration
resource "alertops_inbound_integration" "my_app" {
inbound_integration_name = "My Application"
type = "API"
escalation_policy = alertops_escalation_policy.default.escalation_policy_name
recipient_groups = [alertops_group.ops_team.group_name]
}
Resources
| Resource | What it manages |
|---|---|
alertops_user | Manage AlertOps users with contact methods |
alertops_group | Manage on-call groups and their members |
alertops_schedule | Manage on-call schedules for a group |
alertops_escalation_policy | Manage escalation policies and notification chains |
alertops_response_play | Manage response plays: escalation paths of users and groups with wait times |
alertops_workflow | Manage workflows (conditions and actions, e.g. notify on acknowledge/close) |
alertops_inbound_integration | Manage inbound integrations (API, Email, Heartbeat, etc.) |
alertops_outbound_integration | Manage outbound webhook integrations |
alertops_service | Manage services with uptime tracking |
alertops_maintenance_window | Manage maintenance windows to suppress alerts |
alertops_topic | Manage topics and the groups subscribed to them |
Import existing resources
Every resource can be imported by its AlertOps ID, so you can bring an existing account under Terraform without recreating anything:
terraform import alertops_group.example 12345Each resource page lists the ID it expects. On Terraform 1.5 and later, terraform plan -generate-config-out=generated.tf writes configuration for imported resources.
Upgrading from kamsrikanth/alertops
Earlier versions were published as kamsrikanth/alertops. To move to the official namespace, change source to alertopsofficial/alertops in required_providers, then run:
terraform init -upgrade
terraform state replace-provider registry.terraform.io/kamsrikanth/alertops registry.terraform.io/alertopsofficial/alertopsBehavior notes
- Resources deleted outside Terraform are removed from state and re-created on the next apply.
- Transient 5xx responses are retried up to 3 times for GET, PUT and DELETE. POST requests are never retried, so nothing is created twice.
- Fields the provider does not model yet can be passed with
extra_attributeswhere a resource supports it.