Terraform Provider

Terraform Provider Quick Start Guide

This guide will help you get started with the Status200 Terraform Provider in just a few minutes.

Prerequisites

  • Terraform >= 1.0 installed
  • Status200 account (Cloud or Self-Hosted)
  • Status200 API key

Step 1: Create API Key

For Status200 Cloud

  1. Go to Status200 Cloud and log in
  2. Navigate to SettingsAPI Keys
  3. Click Create API Key
  4. Name it "Terraform Provider"
  5. Select required permissions
  6. Copy the generated API key

For Self-Hosted Status200

  1. Access your Status200 instance
  2. Navigate to SettingsAPI Keys
  3. Click Create API Key
  4. Name it "Terraform Provider"
  5. Select required permissions
  6. Copy the generated API key

Step 2: Create Terraform Configuration

Create a new directory and main.tf file:

terraform {
  required_providers {
    status200 = {
      source  = "status200/status200"
      # For Cloud customers
      version = "~> 7.0"
      
      # For Self-Hosted customers - pin to your exact version
      # version = "= 7.0.123"  # Replace with your Status200 version
    }
  }
  required_version = ">= 1.0"
}

provider "status200" {
  # For Cloud customers
  status200_url = "https://status200.ru"
  
  # For Self-Hosted customers - use your instance URL
  # status200_url = "https://status200.yourcompany.com"
  
  api_key = var.status200_api_key
}

variable "status200_api_key" {
  description = "Status200 API Key"
  type        = string
  sensitive   = true
}

# Note: Projects must be created manually in the Status200 dashboard
# Use your existing project ID here
variable "project_id" {
  description = "Status200 project ID"
  type        = string
}

# Create a simple website monitor
resource "status200_monitor" "website" {
  name        = "Website Monitor"
  description = "Monitor for website uptime"
  data        = jsonencode({
    url = "https://example.com"
    interval = "5m"
    timeout = "30s"
  })
}

# Output the monitor ID
output "monitor_id" {
  value = status200_monitor.website.id
}

Step 3: Create Variables File

Create terraform.tfvars:

# terraform.tfvars
status200_api_key = "your-api-key-here"
project_id        = "your-project-id-here"  # Get this from Status200 dashboard

Important: Add terraform.tfvars to your .gitignore to keep API keys secret!

Step 4: Initialize and Apply

# Initialize Terraform
terraform init

# Plan the deployment
terraform plan

# Apply the configuration
terraform apply

Step 5: Verify Resources

  1. Check your Status200 dashboard
  2. Go to your existing project
  3. Verify the "Website Monitor" is created and running

Next Steps

  1. Explore More Resources: Check the full documentation for all available resources
  2. Set Up Alerting: Add alert policies and notification channels
  3. Create Status Pages: Set up public status pages for your services
  4. Organize with Teams: Create teams and assign permissions

Version-Specific Examples

Cloud Customers (Latest Version)

terraform {
  required_providers {
    status200 = {
      source  = "status200/status200"
      version = "~> 7.0"  # Always gets latest compatible 7.x version
    }
  }
}

provider "status200" {
  status200_url = "https://status200.ru"
  api_key       = var.status200_api_key
}

Self-Hosted Customers (Version Pinned)

terraform {
  required_providers {
    status200 = {
      source  = "status200/status200"
      version = "= 7.0.123"  # Must match your Status200 version exactly
    }
  }
}

provider "status200" {
  status200_url = "https://status200.mycompany.com"  # Your self-hosted URL
  api_key       = var.status200_api_key
}

Troubleshooting Quick Start

Issue: Provider not found

Error: Failed to query available provider packages

Solution: Run terraform init to download the provider

Issue: Authentication failed

Error: Invalid API key

Solution:

  1. Verify your API key in Status200 dashboard
  2. Check the API key has sufficient permissions
  3. Ensure status200_url is correct for your instance

Issue: Version mismatch (Self-Hosted)

Error: API version incompatible

Solution:

  1. Check your Status200 version in the dashboard
  2. Update the provider version to match exactly
  3. Run terraform init -upgrade

Clean Up

To remove all resources created in this quick start:

terraform destroy

This will delete the monitor and project created during the quick start.