TERRAFORM

There’s a better way to monitor your assets

Defining your checks as code with Checkly’s Terraform provider makes monitoring large websites and APIs a breeze.

checkly code
payment-check.tf
resource "checkly_check" "stripe-charges" {
  name                      = "Stripe Charges"
  type                      = "API"
  activated                 = true
  frequency                 = 1
  ssl_check                 = true
  use_global_alert_settings = true
  locations = ["eu-central-1"]
  request {
    url        = "https://api.stripe.com/v1charges"
    follow_redirects = true
    assertion {
      source     = "STATUS_CODE"
      comparison = "EQUALS"
      target     = "200"
    }
}

Your app’s code lives in source control.
Your monitoring should too.

checkly code

Compatible with your workflow

Already using Terraform for IaC? Great. Not using Terraform yet? Easily plug it into your existing pipeline.

checkly code

Increased transparency

Declaring your checks as code aligns your monitoring with your releases and rollbacks, while also serving as documentation.

checkly code

One setup for local and cloud

Seamlessly develop and test your checks locally, push to source control and apply automatically.

Provision all you need in just seconds

Managing your checks, groups, alert channels and other monitoring resources should never be the bottleneck for shipping more code or increasing visibility into the state of your systems.

main.tf
resource "checkly_check" "add-to-cart" {
 name = "Add to cart"
 type = "BROWSER"
 frequency = 5
 activated = true
 locations = ["us-west-1", "eu-central-1"]
 script = file("${path.module}/scripts/add-to-cart.js")
}
main.tf
resource "checkly_check_group" "purchase" {
  name = "Purchase"
  activated = true
  concurrency = 5
  locations = [ "us-west-1", "eu-central-1"]
}

resource "checkly_check" "add-to-cart" {
  name = "Add to cart"
  type = "BROWSER"
  frequency = 5
  activated = true
  locations = [ "us-west-1", "eu-central-1" ]
  script = file("${path.module}/scripts/add-to-cart.js")
  group_id = checkly_check_group.purchase.id
}

resource "checkly_check" "payment" {
  name = "Payment"
  type = "API"
  frequency = 1
  activated = true
  locations = [ "us-west-1", "eu-central-1" ]
  request {
    url = "https://webshop.com/api/charges"
    assertion {
      source = "STATUS_CODE"
      comparison = "EQUALS"
      target = "200"
    }
  }
  group_id = checkly_check_group.purchase.id
}
main.tf
resource "checkly_alert_channel" "pagerduty_ac" {
  pagerduty {
    account = "checkly"
    service_key = "key1"
    service_name = "pdalert"
  }
}

resource "checkly_alert_channel" "email_ac" {
  email {
    address = "john@acme.com"
  }
}

resource "checkly_check_group" "purchase" {
  name = "Purchase"
  activated = true
  concurrency = 5
  locations = ["us-west-1", "eu-central-1"]
}

resource "checkly_check" "add-to-cart" {
  name = "Add to cart"
  type = "BROWSER"
  frequency = 5
  activated = true
  locations = ["us-west-1", "eu-central-1"]
  script = file("${path.module}/scripts/add-to-cart.js")
  group_id = checkly_check_group.purchase.id
  alert_channel_subscription {
    channel_id = checkly_alert_channel.pagerduty_ac.id
    activated = true
  }
  alert_channel_subscription {
    channel_id = checkly_alert_channel.slack_ac.id
    activated = true
  }
}

resource "checkly_check" "payment" {
  name = "Payment"
  type = "API"
  frequency = 1
  activated = true
  locations = ["us-west-1", "eu-central-1"]
  request {
    url = "https://webshop.com/api/charges"
    assertion {
      source = "STATUS_CODE"
      comparison = "EQUALS"
      target = "200"
    }
  }
  group_id = checkly_check_group.purchase.id
  alert_channel_subscription {
    channel_id = checkly_alert_channel.email_ac.id
    activated = true
  }
}

Scale across teams and projects

Need hundreds or thousands of checks running at all times, giving teams the flexibility to manage their own resources independently? We take the power of IaC and apply it to monitoring.

checkly code

Hear about it from our customers

"Checkly integrated with Terraform enables us to quickly create, modify, and deploy API and browser checks for a broad and diverse audience of internal customers."

Andreas Lehr

Team Lead at Schwarz Group IT

Get Started

1

Get the installation code

Copy the installation code and save it in your Terraform file.

OR
variable "checkly_api_key" {}
variable "checkly_account_id" {}

terraform {
  required_providers {
    checkly = {
      source = "checkly/checkly"
      version = "~> 1.0"
    }
  }
}

provider "checkly" {
  api_key = var.checkly_api_key
  account_id = var.checkly_account_id
}
2

Export your credentials

Find your API key and account ID in your user settings, then export them as environment variables.

$ export TF_VAR_checkly_api_key={YOUR_API_KEY}
$ export TF_VAR_checkly_account_id={YOUR_ACCOUNT_ID}
3

Run it

Initialize and apply your Terraform config.

$ terraform init
$ terraform apply

Try out Checkly for free

Start monitoring your API endpoints and your vital site transactions.

no credit card required