Skip to content

About

[Cloud] Get started with LIVCK and Terraform: monitors, a status page and charts from one config

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LIVCK with Terraform

Your monitoring and your public status page, kept in git and rolled out with terraform apply. This repo is a working starting point: clone it, point it at your services, and you have monitors, a status page, charts and a maintenance window from one file.

Works with Terraform 1.5+ and with OpenTofu.

What you get

The root config creates:

  • three services (two HTTP checks and one TCP check), tagged env:production
  • a status page with a "Core services" group, uptime bars, and a component that has no check behind it (for the things you flip by hand)
  • a response-time chart with the website and the API in the same graph
  • a maintenance window, announced on the page, that starts itself

The defaults point at example.com, so the first apply comes up green before you have changed a thing. Swap in your own targets when you are ready.

Get a token

In the console, go to Settings > API Tokens and create one (Team plan or higher). This example needs:

services.view      services.create      services.edit      services.delete
statuspages.view   statuspages.create   statuspages.edit   statuspages.delete
maintenances.view  maintenances.create  maintenances.edit  maintenances.delete

If you want the page to go live from Terraform, add statuspages.publish.

Run it

export LIVCK_API_TOKEN="lvk_..."

terraform init
terraform apply

Open the statuspage_url output in a browser. Then run terraform plan again: it should report no changes. That empty plan is the point of the whole exercise. What you wrote down is what LIVCK serves back.

To use your own services, copy terraform.tfvars.example to terraform.tfvars and edit it. That file is gitignored.

Change something

Rename a component, add a service, add a probe to var.probes, and apply again. A few things worth trying:

# Check from two locations instead of one
terraform apply -var='probes=["ffm","vie"]'

# See where you can check from
terraform output probe_locations

Probes are referenced by their code (ffm, vie, waw), not by an id, so the config stays readable. How many locations one service may use depends on your plan; go over it and the API says so.

Import what you already have

If you built things in the console first, bring them under Terraform without recreating them:

terraform import livck_service.website     <service_id>
terraform import livck_statuspage.main     <statuspage_id>
terraform import livck_tag.env             <tag_id>

# Nested resources take the parent id first
terraform import livck_statuspage_component.website  <statuspage_id>/<component_id>
terraform import livck_statuspage_metric.latency     <statuspage_id>/<metric_id>
terraform import livck_statuspage_metric_series.latency_website \
    <statuspage_id>/<metric_id>/<series_id>

The ids are in the console URLs and in every API response.

One caveat: a few things cannot be read back, because the API never returns them. Secrets inside a service config, a status page password, the local path of an uploaded logo, and the maintenance notify flags all fall into that category. After importing such a resource the first plan shows a one-off change that writes your configured values back. Apply it once and you are in sync.

Clean up

terraform destroy

A bigger example

examples/public-dns-watch/ monitors Cloudflare, Google and Quad9 from several European probes. It is the one to read if you want to see for_each over a map of targets, three check types next to each other, and charts that compare all three resolvers in a single graph.

Files

File What it holds
versions.tf provider requirement
provider.tf provider config, token comes from the environment
variables.tf targets, probes, endpoint
main.tf the setup itself
outputs.tf status page URL, probe list, service ids
terraform.tfvars.example copy to terraform.tfvars and edit

Pointing at something other than LIVCK Cloud

Set endpoint in terraform.tfvars, for example a local development stack:

endpoint = "http://localhost:8000/api"

About

[Cloud] Get started with LIVCK and Terraform: monitors, a status page and charts from one config

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages