Quick Start
This guide takes you from nothing to a Status200 project managed by Terraform in about ten minutes. You create an API key, point Terraform at your project, and apply a label, a monitor that checks your website, and a private status page that shows it. Then you change one of them and clean up.
What you build in this guide
Before you begin
- Terraform 1.5 or later, or OpenTofu 1.6 or later. With OpenTofu, run
tofuwherever this guide runsterraform. - A Status200 project on status200.ru or on your own Status200, in which you can create API keys.
- On Status200 Cloud, the Growth plan or above. A project's API keys work only on it.
Create your first resources
Create a project API key
In the Status200 dashboard, open Project Settings → Advanced → API Keys and click Create API Key. Give it a Name, such as
terraform, and under Access pick Project Admin: Terraform creates, reads, changes and deletes every kind of record it manages, and Project Admin may do all of that. For a narrower key, pick Choose permissions later and add only the permissions you need on the key's page.The key expires a year from today. To pick another date, open More fields before you create it, or change the date on the key's page later. Once the key is created, its page opens: copy the API Key from the API Key Details card.
Make the key available to Terraform
Put the key in the
STATUS200_API_KEYenvironment variable of the shell you run Terraform in, so it never lands in a file:Linux
export STATUS200_API_KEY="<your-api-key>"macOS
export STATUS200_API_KEY="<your-api-key>"Windows
$env:STATUS200_API_KEY = "<your-api-key>"Point Terraform at Status200
Make an empty folder, and in it a file named
main.tf:terraform { required_providers { oneuptime = { source = "oneuptime/status200" version = "~> 14.0" } } } provider "oneuptime" { # The API key comes from STATUS200_API_KEY. # On a self-hosted Status200, add your Status200's address: # status200_url = "https://status200.example.com" }On a self-hosted Status200, read Self-Hosted Setup before you pick a provider version.
Describe your resources
Add these blocks to
main.tf. They read two of the monitor statuses every project starts with, and create a label, a monitor that checkshttps://example.comevery five minutes (put your own website there), and a private status page that shows the monitor:data "status200_monitor_status" "operational" { name = "Работает" } data "status200_monitor_status" "offline" { name = "Не в сети" } resource "status200_label" "critical" { name = "critical" description = "Resources that page on-call when down" color = "#FF5733" } resource "status200_monitor" "homepage" { name = "Homepage" description = "Checks that the homepage responds" monitor_type = "Website" monitoring_interval = "*/5 * * * *" labels = [status200_label.critical.id] monitor_steps = [{ monitor_destination = "https://example.com" monitor_destination_type = "URL" request_type = "GET" criteria = [ { name = "Offline" description = "The homepage does not respond" filter_condition = "Any" change_monitor_status = true monitor_status_id = data.status200_monitor_status.offline.id filters = [ { check_on = "Is Online" filter_type = "False" } ] }, { name = "Online" description = "The homepage responds" filter_condition = "All" change_monitor_status = true monitor_status_id = data.status200_monitor_status.operational.id filters = [ { check_on = "Is Online" filter_type = "True" } ] } ] }] } resource "status200_status_page" "internal" { name = "Internal Status" description = "Status of our internal services" page_title = "Service Status" is_public_status_page = false } resource "status200_status_page_resource" "homepage" { status_page_id = status200_status_page.internal.id monitor_id = status200_monitor.homepage.id display_name = "Homepage" } output "monitor_id" { value = status200_monitor.homepage.id }The monitor's
monitor_stepssay what it checks and what each result means: after each check, the first criteria that matches sets its status. Monitor Steps explains every part.Plan and apply
Terraform
terraform init terraform plan terraform applyOpenTofu
tofu init tofu plan tofu applyinitdownloads the provider. The plan ends withPlan: 4 to add, 0 to change, 0 to destroy.Typeyesto apply it; when it is done, Terraform prints the new monitor's ID.Check the dashboard
In the Status200 dashboard:
- Monitors lists
Homepage, with thecriticallabel. Its first check is in within a few minutes. - Status Pages lists
Internal Status, which showsHomepage. - Project Settings → Basic → Labels lists
critical, in the color you set.
Run
terraform planagain. It answersNo changes.: Status200 holds exactly what the configuration says.- Monitors lists
Change a resource
Change the configuration, not the dashboard. Set the label's color to "#2ECC71" in main.tf, then plan and apply:
terraform plan
terraform applyThe plan ends with Plan: 0 to add, 1 to change, 0 to destroy.: the label is changed in place. A change someone makes in the dashboard to a resource Terraform manages shows in the next plan, and applying it puts back what the configuration says.
Clean up
If this was a test drive, delete what the configuration created:
terraform destroyIt deletes the label, the monitor, the status page and its resource. The two monitor statuses stay: the data sources only read them.
Troubleshooting
Missing API Key
The provider found no API key. Export STATUS200_API_KEY in the shell you run Terraform in, or set api_key in the provider block, and run the command again.
The Status200 API returned status 400: Invalid API Key
The key is mistyped, expired or deleted, or it belongs to another Status200 than the one status200_url points at. Copy the key again from its page, or create a new one.
The Status200 API returned status 402: API keys need the Growth plan
On Status200 Cloud, a project's API keys work only on the Growth plan or above. Upgrade the project in Project Settings → Billing and Invoices → Billing, and the same key works again.
The Status200 API returned status 422: You do not have permissions to create Monitor
The key has no permission for that kind of record. On the key's page, give it Project Admin, or the permission the message names.
No monitor status matches {name = "Не в сети"}
Your project's monitor statuses have other names. Use the names you see in Monitors → Settings → Monitor Status, or look the status up by is_offline_state = true instead.