The growing prevalence of cloud-delivered services has advanced the approach of Infrastructure as Code (IaC). IaC empowers development teams to efficiently provision, configure, and activate server, network, and application infrastructures, and components within cloud environments.
The users of digital services today demand not just availability from their applications but also insist on consistent, reliable performance. A sudden increase in application latency can be devastatingly impactful to the users, even if the service remains up and reachable. Therefore, continuous performance assurance of these digital services is no longer a nice to have but a must-have requirement.
Introducing the ThousandEyes Terraform Provider
Terraform is a popular open-source IaC software tool created by HashiCorp and used to deploy cloud-hosted digital services. And as of today, ThousandEyes customers can take advantage of our newly developed Terraform provider, a Terraform plugin that allows users to manage ThousandEyes tests and create alerts using Terraform.
Terraform deployment of ThousandEyes enables SREs and DevOps teams to automate the rollout of critical performance monitoring as part of their application deployment pipeline. By configuring ThousandEyes with Terraform, these IT teams can streamline their application monitoring and facilitate the creation of standardized testing profiles for all important services.
Because ThousandEyes is a verified provider in the Terraform Registry, our customers can easily and quickly install the ThousandEyes provider using Terraform. This post will cover the supported options and walk you through the initial configuration.
Before We Begin
The ThousandEyes provider leverages the ThousandEyes Go SDK, which you can read more details about here on GitHub.
As of this version (1.3.1), the plugin supports the following resources:
- agent-to-agent
- agent-to-server
- alert-rule
- bgp
- dnssec
- dns-server
- dns-trace
- ftp-server
- http-server
- page-load
- sip-server
- voice (RTP stream)
- web-transactions
The walkthrough outlined in the following section assumes you have Terraform and Go configured on your local system. If you don’t currently have them setup, please see the following links for more details:
You can verify that these tools are configured properly in your environment by running these two commands:
terraform --version
go version
Note that once the ThousandEyes provider is successfully installed, the terraform --version
command will additionally show which providers are installed.
Setup
Now we’ll walk through getting the Terraform provider up and running with a sample configuration.
Install ThousandEyes Terraform Provider
We’ll start by installing the ThousandEyes Terraform Provider in our environment. The instructions can be found within the README.md on the ThousandEyes Terraform Provider GitHub repository.
The first step is to create a Terraform config file that leverages the ThousandEyes provider.
Here’s an example configuration that applies the ThousandEyes provider and creates an HTTP server test with the following parameters:
- Test Name: Example HTTP test set from Terraform provider
- Test type: HTTP Server
- Test Interval: 120 seconds
- Alerts Enabled: No
- URL To Test: https://www.thousandeyes.com
- Assigned ThousandEyes agents: Cordoba, Argentina cloud agent
An optional part of the configuration is specifying a ThousandEyes account group ID, which is an identifier for the specific account group in which you want this configuration to deploy into. In order to retrieve an account group ID, the ThousandEyes API can be leveraged to pull this information. A reference for this process can be found in the ThousandEyes Developer Reference
Example:
$ curl https://api.thousandeyes.com/v6/account-groups.json \
-u {email}:{authToken}
Response:
{
"accountGroups": [
{
"accountGroupName": "API Sandbox",
"aid": 75,
"current": 1,
"default": 1
}
]
}
In this sample response, the account ID (AID) is 75.
Sample Basic Configuration
terraform {
required_providers {
thousandeyes = {
source = "thousandeyes/thousandeyes"
version = ">=1.3.1"
}
}
}
provider "thousandeyes" {
token = "<insert your OAuth bearer token here>"
account_group_id = "<insert your account group here>"
}
data "thousandeyes_agent" "arg_cordoba" {
agent_name = "Cordoba, Argentina"
}
resource "thousandeyes_http_server" "www_thousandeyes_http_test" {
test_name = "Example HTTP test set from Terraform provider"
interval = 120
alerts_enabled = false
url = "https://www.thousandeyes.com"
agents {
agent_id = data.thousandeyes_agent.arg_cordoba.agent_id
}
}
Your OAuth bearer token key is a ThousandEyes account user-specific key used to authenticate against the ThousandEyes API. The token can be generated within the ThousandEyes GUI under Account Settings → Users and Roles → User API Tokens
Prepare and Run Terraform Plan
We’ve successfully installed the ThousandEyes Terraform Provider. Now we can initialize our Terraform directory, view the plan, and then deploy the configuration using Terraform.
We’ll want to move into our ThousandEyes Terraform directory and then issue the terraform init
command to prepare the folder:
cd <terraformpath>
terraform init
You will see the "Terraform has been successfully initialized!" message, which means we are ready to proceed with executing our config. We will first use the terraform plan
command to view which changes will be made and validate that everything looks good with the configuration:
terraform plan
If all looks good, you can now execute the configuration by issuing the terraform apply
command.
You’ve now successfully added a test configuration to your ThousandEyes environment using the Terraform provider! While this is only scratching the surface of what you can deploy with ThousandEyes, you now have the basic foundation on which to build more advanced ThousandEyes tests.
Below you can find a sample configuration that is a little more advanced and applies alert rules and multiple ThousandEyes agents.
Sample Advanced Configuration
terraform {
required_providers {
thousandeyes = {
source = "thousandeyes/thousandeyes"
version = ">= 1.3.1"
}
}
}
provider "thousandeyes" {
token = "<insert your OAuth bearer token here>"
account_group_id = "<insert your account group here>"
}
data "thousandeyes_agent" "arg_cordoba" {
agent_name = "Cordoba, Argentina"
}
data "thousandeyes_agent" "arg_bsas" {
agent_name = "Buenos Aires, Argentina"
}
resource "thousandeyes_alert_rule" "test_alert_rule" {
rule_name = "Test rule from Terraform"
alert_type = "HTTP Server"
expression = "((errorType != \"None\"))"
minimum_sources_pct = 100
rounds_violating_out_of = 10
rounds_violating_required = 10
notifications {
email {
recipient = [
"example@thousandeyes.com"
]
}
}
}
resource "thousandeyes_alert_rule" "test_alert_rule-2" {
rule_name = "Test rule 2 from Terraform"
alert_type = "HTTP Server"
expression = "((errorType != \"None\"))"
minimum_sources_pct = 100
rounds_violating_out_of = 10
rounds_violating_required = 10
notifications {
email {
recipient = [
"example@thousandeyes.com"
]
}
}
}
resource "thousandeyes_http_server" "www_thousandeyes_http_test" {
test_name = "Terraform testing: Example HTTP test set from Terraform provider"
interval = 120
alerts_enabled = true
url = "https://www.thousandeyes.com"
agents {
agent_id = data.thousandeyes_agent.arg_cordoba.agent_id
}
agents {
agent_id = data.thousandeyes_agent.arg_bsas.agent_id
}
alert_rules {
rule_id = thousandeyes_alert_rule.test_alert_rule.rule_id
}
alert_rules {
rule_id = thousandeyes_alert_rule.test_alert_rule-2.rule_id
}
}
With this sample configuration above, Terraform will remove the previous test we created in our initial simple configuration plan and will then add in the new test and alert configurations that we’ve defined.
Conclusion
Today’s digital services need not just reachability and availability; consistent, reliable performance of user experience is a must. By leveraging the automation capabilities already in use for service delivery, customers can now roll ThousandEyes into the same deployment pipeline.
ThousandEyes test configuration deployments can be standardized and version-controlled using GitHub, giving confidence and control to the teams responsible for operating application cloud infrastructures.
Terraform delivers a powerful and flexible platform for deploying not just the cloud systems and application components but also enables development teams to efficiently deploy critical performance monitoring alongside every delivered digital cloud service and application.
ThousandEyes is committed to the ongoing development and support of the ThousandEyes Terraform Provider and would like to thank the Terraform community members, especially William Fleming, John Dyer, and Joshua Blanchard, for their many contributions to this project.