Looking for Monitoring as Code but don’t want to use Terraform? Give our CLI solution a try.
Installation
To get started, you first need to install Terraform. Next, switch to a new folder for your project, and create yourmain.tf file:
Terminal
main.tf:
main.tf
Create API key.
Get your User API key and add it to your env using your terminal:
Terminal
Terminal
terraform init will install the Checkly Terraform provider for you, as well as initialising your project. The output will look similar to the following:
Terminal
Your first browser check
As an example, you could add a basic browser check resource at the bottom of yourmain.tf.
main.tf
Applying changes
You can now have Terraform apply your changes on Checkly by runningterraform apply. Terraform will draft a plan and ask you to confirm by typing yes. Once that is done, Terraform will go ahead and create the resources you have specified (one browser check, so far) for you.
Terminal
Adding an API check
You can also add an API check to monitor an API endpoint:main.tf
terraform apply or wait until we have added an alert channel and have Terraform create both resources at once.
Setting up alerts
Now that you have your checks set up, you’ll want to set up an alert channel for Checkly to promptly inform you when one of them fails. For example, you could create an email channel:main.tf
main.tf
terraform apply for the last time and have Terraform create your checks and alert channel for you.
Congratulations! You have created your first Checkly monitoring setup using Terraform.