Skip to main content
By the end of this guide, your shop’s monitoring lives in five Terraform resources: an email alert channel, a check group that owns locations, retries, and alerting, two Browser Checks loaded from Playwright spec files, and an API check that asserts on the response body.
Terminal
To follow along without your own app, clone the sample project. It monitors the Danube demo shop and its /api/books endpoint.
To run this guide from your terminal or your coding agent, run npx checkly init in your project first. It installs the Checkly CLI and Checkly Skills for your agent. Then paste the prompt below into Claude Code, Cursor, Codex, or any agent that supports skills. It builds the same setup as this guide, proves it with npx checkly test --record, and stops for your confirmation before npx checkly deploy.
Prompt
For this guide, the agent proves the setup with npx playwright test and terraform plan, and stops before terraform apply. The steps below are what it does, in the open.

Step 1: Configure the provider

Start in an empty folder. The provider needs a Checkly user API key and the ID of the account to create resources in. Declare both as variables so they never land in a file you commit.
providers.tf
Terraform reads any variable from an environment variable prefixed with TF_VAR_. The Terraform provider overview shows where to find both values in the app.
Terminal
Terminal

Step 2: Decide who hears about failures

A check that fails without telling anyone is a dashboard, not monitoring. Create the alert channel first, so everything after it can subscribe.
alerts.tf
Set the address the same way as the credentials, with export TF_VAR_alert_email="you@yourcompany.com". Email is the simplest channel to start with. The same resource takes Slack, PagerDuty, Opsgenie, SMS, and webhook blocks; see alert channels for Terraform.

Step 3: Put shared settings in one group

Every check for the shop should run from the same places, retry the same way, and alert the same people. Declare that once on a group instead of repeating it on every check.
group.tf
checkly_check_group_v2 changes nothing about its checks unless you ask it to. Each enforce_ block you add takes that setting away from the checks and applies the group’s value instead. Here the group runs every check from N. Virginia and Ireland in parallel, retries a failed run up to twice from a different region, and emails you as soon as one run still fails after its retries. The SHOP_URL variable reaches every Browser Check in the group. Point the whole stack at a staging shop with terraform plan -var="shop_url=<your staging URL>", without touching a check.

Step 4: Monitor the shop’s flows with Browser Checks

Keep each flow in its own Playwright spec file. The file is the check’s script, and you can run it locally before Terraform ever sees it.
The search test asserts the exact list of results, so a search that returns the wrong books fails as surely as one that returns nothing. Install Playwright and run both specs:
Terminal
Terminal
Now turn every spec into a check. A for_each over a map creates one Browser Check per entry, and file() reads the spec as the check’s script:
browser.tf
The checks set only what is theirs: a name, a script, and how often to run. Everything else comes from the group. For the checkout itself, with test data that stays out of your sales numbers, follow Monitor a checkout flow.

Step 5: Assert on the product API

The storefront renders whatever /api/books returns. If the API answers 200 with an empty list, the pages load and show nothing to buy. An API check catches that every minute, without starting a browser.
api.tf
Three assertions, three different failures: the API is down, it returns an HTML error page, or it returns an empty catalog. Responses slower than one second are degraded, and slower than three seconds fail.

Step 6: Plan, then apply

Check the formatting and the configuration, then ask Terraform what it would create:
Terminal
The plan lists all five resources. This part of the group block shows settings it enforces on its checks:
Terminal
When the plan matches what you expect, run terraform apply and type yes to create the checks in your account. From then on, the folder is the source of truth. Change a file, run terraform plan to see the difference, and apply.
Manage these resources in Terraform or in the Checkly app, not both. Changing Terraform-managed resources in the app, and vice versa, is likely to cause issues.

Verify it works

Break a check before it reaches production. In scripts/search.spec.ts, change 'Baiting for Robot' to 'Waiting for Robot' and run the specs again:
Terminal
Terminal
The failure names the flow and the exact result that changed, and the home page check still passes. Nothing reached Checkly, because only terraform apply changes a check. Once the checks exist, the same edit shows up in terraform plan as a change to that check’s script, so a reviewer sees the monitoring change next to the code change. Put 'Baiting for Robot' back.

Next

Run checks on every deploy: terraform apply keeps your monitoring in step with your code. Run the checks against each deploy too, so a broken release fails before it reaches the schedule.

Reference