# Checkly Terraform Provider

**Source**: https://www.checklyhq.com/product/terraform-provider/

> The Checkly provider adds checks, groups, alert channels, status pages, and private locations to the HCL you already review, plan, and apply. Same pull request, same state, same pipeline as the services they watch.

## What it does

- **Monitors show up in the same diff as the service**: a new endpoint and the check that watches it land in one pull request. Reviewers see the assertion next to the route, and `terraform plan` tells everyone what changes before anything runs.
- **State owns the lifecycle**: rename a check, move it into a group, or delete the service it covered, and apply reconciles the account to match. No orphaned monitors paging for an API that no longer exists.
- **The whole setup, not just checks**: groups, alert channels, status pages, dashboards, maintenance windows, private locations, snippets, and environment variables are all resources. One apply stands up the full account.
- **Check, group, alert channel**: a browser check is a Playwright script in your repo referenced by path. A `checkly_check_group` carries shared settings; point a check at it with `group_id`. Alert channels are standalone resources; subscribe the group once and every check inside it pages the same on-call rotation.
- **Review the diff before it pages anyone**: apply from your laptop, from CI, or from Terraform Cloud on every push to main, with state in the remote backend you already run.

## Get started in three steps

1. **Add the provider**: pin `checkly/checkly` from the Terraform Registry with `version = "~> 1.0"` and pass credentials through variables.
2. **Export your credentials**: `TF_VAR_checkly_api_key` and `TF_VAR_checkly_account_id`, both from your Checkly settings.
3. **Init and apply**: `terraform init` then `terraform apply`. Or clone the getting-started repository.

## Terraform or the Checkly CLI?

The Checkly CLI is the primary monitoring-as-code path: TypeScript constructs, a local test run before deploy, and a project structure built for monitors. Pick Terraform when your team already manages infrastructure in Terraform and wants monitors in the same state, plan, and pipeline. Both talk to the same Checkly account.

## Key facts

- Provider: `checkly/checkly` on the Terraform Registry, HashiCorp **partner** tier, current major version **1.x**.
- Resources include `checkly_check`, `checkly_check_group`, `checkly_alert_channel`, `checkly_playwright_check_suite`, `checkly_url_monitor`, `checkly_tcp_monitor`, `checkly_dns_monitor`, `checkly_icmp_monitor`, `checkly_heartbeat_monitor`, `checkly_status_page`, `checkly_dashboard`, `checkly_maintenance_windows`, `checkly_private_location`, `checkly_snippet`, `checkly_environment_variable`, and command line triggers.
- Manage each resource either through Terraform or through the UI, never both.

## Customer quotes

> "We chose Checkly because of the Terraform provider that was available out of the box. Another important thing for us was the fact that we could automate the generation of the checks from Terraform."
> Alessio Casco, Head of DevOps at TrueLayer

## Frequently Asked Questions

### What is the Checkly Terraform provider?
It is the official checkly/checkly provider on the Terraform Registry, published under the HashiCorp partner tier. It lets you declare Checkly checks, groups, alert channels, and the rest of your monitoring account as HCL resources, then create and update them with terraform plan and terraform apply. The current major version is 1.x, so a version constraint of "~> 1.0" tracks it.

### Which Checkly resources can I manage with Terraform?
API, browser, and multistep checks (checkly_check), Playwright check suites, URL, TCP, DNS, ICMP, and heartbeat monitors, check groups, alert channels, status pages, dashboards, maintenance windows, private locations, code snippets, environment variables, and command line triggers. The full resource list with every argument is on the Terraform Registry documentation for the provider.

### Should I use the Terraform provider or the Checkly CLI?
The Checkly CLI is the primary monitoring-as-code path: TypeScript constructs, a local test run before deploy, and a project structure built for monitors. Pick Terraform when your team already manages infrastructure in Terraform and wants monitors in the same state, plan, and pipeline. Both talk to the same Checkly account and expose the same check types.

### Can I edit a Terraform-managed check in the Checkly web app?
You should not. Checkly resources should be managed either through Terraform or through the UI, not both. Changing a Terraform-managed check in the app puts it out of sync with your state, and the next apply will either revert the change or fail. Keep each resource in one place.

### How do groups affect locations and alerting?
When a check has a group_id, the group settings decide which locations it runs from and which alert channels it is subscribed to. Group-level alert channel subscriptions override check-level ones, so the simplest setup is to subscribe the group once and let every check inside it inherit the subscription.

### Does it work with Terraform Cloud and CI/CD pipelines?
Yes. The provider runs anywhere Terraform does. If more than one machine or person applies the configuration, use a remote backend so the state stays in sync; Terraform Cloud handles that for you and can auto-apply on every push to your default branch.

### How do I test a browser check script before I apply it?
Browser check scripts are plain Playwright, so run them locally with npx playwright test before referencing them from a checkly_check resource with file(). If the script imports shared helpers, declare those files as checkly_snippet resources so they are available when the check runs on Checkly.

## Related

- [Terraform Provider (full page)](https://www.checklyhq.com/product/terraform-provider/)
- [Terraform provider docs](https://www.checklyhq.com/docs/integrations/iac/terraform/overview/)
- [Provider on the Terraform Registry](https://registry.terraform.io/providers/checkly/checkly/latest/docs)
- [Pulumi Provider](https://www.checklyhq.com/product/pulumi-provider/)
- [Monitoring as Code](https://www.checklyhq.com/product/monitoring-as-code/)
- [Alerting](https://www.checklyhq.com/product/alerting/)
- [Start for free](https://app.checklyhq.com/signup/)
