SaC - How to build status pages as code with Terraform

Marko Simon
October 13, 2022
Table of Contents:

Status pages are a clever solution to bundle all your services, and see the status of them at one sight. We at ilert took this one step further: why not build your status page as code using Terraform? We want to show you how we make it possible, and how you can set it up for your own infrastructure - a real SaC solution.

Hashicorp’s Terraform is widely used for deploying and manging infrastructure as code. In our previous blogpost to Terraform we covered all the basics for setting up the ilert Terraform Provider and an alerting infrastructure. If you need more in depth information on the setup or if you are stuck you can find more information there. We will now step through the whole process: from creating your first alert source to deploying a status page with automation rules via code with Terraform.


You will need:


A quick overview of what you need to set up:

  • your ilert account
  • a local installation of Terraform

Additionally, you will need to clone the example repository from GitHub.

git clone

You also need to provide your ilert credentials either as variables in terraform apply, or store it in a separate file named terraform.tfvars. Create a file in the repository root directory named terraform.tfvars, and Terraform will automatically detect and set those variables on every apply.

organization = "your organization e.g. tenant"
api_token    = "your api token"
// username     = "your username"
// password     = "your password"

To finish your setup you have to initialize Terraform to use it in your directory. Simply run terraform init and the initialization should be done after provider installation.

ilert infrastructure

Before applying any code here’s an overview of the resources and their relations you will be creating in ilert.

iLert resource connections

In short: we send an event to an alert source which triggers an alert. An automation rule connects the alert source and a service by changing the services status when the alert source fires an alert. Therefore when the status of the service changes the statuspage will monitor this and display the current status of the service.

Create a status page


First you have to configure an alert source and provide an escalation policy.

data "ilert_escalation_policy" "default" {
  name = "Default"

resource "ilert_alert_source" "example" {
  name              = "Example alert source from terraform"
  integration_type  = "API"
  escalation_policy =


To create a status page you also need a service which will be contained in the status page.

resource "ilert_service" "example" {
  name = "blogpost_example"

resource "ilert_status_page" "example" {
  name       = "My Statuspage"
  subdomain  = ""
  visibility = "PRIVATE"

  service {
    id =

Note: A subdomain must be unique, you may have to change it to another fitting name.

Automate a status page

Firing an alert or setting the status of the service manually is not desirable in 24/7 monitoring. An automation rule fits in perfect for that task: it connects the alert source to our service and helps us to automatically change the status of our service on an incoming alert.

resource "ilert_automation_rule" "example" {
  alert_type     = "CREATED"
  service_status = "DEGRADED"
  service {
    id =
  alert_source {
    id =

If you now run terraform apply you should see cli output like this:

terraform apply output

You have successfully configured an alert source and an escalation policy and also built a statuspage containing a service while automating via automation rule.

status page operational

Fire up your browser and visit to check out the page you have just created :)

Run the automation

To put everything to test you have to trigger an alert, means sending an event to the ilert events endpoint. For that you have to put in your alert source integration key into apiKey in event.json.

    "apiKey": "your alert source integration key",
    "eventType": "ALERT",
    "summary": "Test alert"

This key can be found in the terraform state file terraform.tfstate or in the ilert UI under the alert source.

integration key

Now you send the event to trigger an alert:

curl -d "@event.json" -H 'Content-Type: application/json' -X POST

An alert was created, the automation rule detected this and set the status of our service to ‘Degraded’, hence the status page shows the outage.

status page degraded

Destroying all created infrastructure

By using terraform destroy all of the created resources will be destroyed and removed from your ilert account.

Note: If you haven’t resolved the alert triggered from the alert source you won’t be able to delete it. Please resolve the alert first.

Observability can be easy

Building your status page as code with the ilert Terraform Provider simplifies the process of building consistent observability for your own services a lot. An ilert status page gives you the important information at first sight while providing details when needed.

If you are interested in knowing more about ilert status pages - take a look at our docs.

A fully executable sample of the shown code can be found on Github in our corresponding example repository.

Other blog posts you might like:

ISDN Alarm System - Switch to VoIP

Read article ›

Auto-raise support hours as morning alarm with Rust

Read article ›

The GSM Modem and Pager Alternative

Read article ›

Get started with ilert

A better way to be on-call for your team.

Start for Free
Our Cookie Policy
We use cookies to improve your experience, analyze site traffic and for marketing. Learn more in our Privacy Policy.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.