- Site24x7 Website: https://www.site24x7.com
- Terraform Website: https://www.terraform.io
- Tutorials: learn.hashicorp.com
- Mailing List: Google Groups
The Terraform Site24x7 provider is a plugin for Terraform that allows for the full lifecycle management of Site24x7 resources. This provider is maintained by Site24x7 team.
Please note: If you believe you have found a security issue in the Terraform Site24x7 Provider, please responsibly disclose by contacting us at [email protected].
- Terraform 0.13+
To use the latest version of the provider in your Terraform environment, run terraform init
and Terraform will automatically install the provider.
For Terraform version 0.13.x
terraform {
required_version = "~> 0.15.0"
required_providers {
site24x7 = {
source = "site24x7/site24x7"
}
}
}
A terraform provider for managing the following resources in Site24x7:
- Amazon Monitor - site24x7_amazon_monitor (Site24x7 Amazon Monitor Terraform doc)
- Website Monitor - site24x7_website_monitor (Site24x7 Website Monitor API doc)
- DNS Server Monitor - site24x7_dns_server_monitor (Site24x7 DNS Server Monitor API doc)
- Web Page Speed (Browser) Monitor - site24x7_web_page_speed_monitor (Site24x7 Web Page Speed Monitor API doc)
- SSL Certificate Monitor - site24x7_ssl_monitor (Site24x7 SSL Certificate Monitor API doc)
- Rest API Monitor - site24x7_rest_api_monitor (Site24x7 Rest API Monitor API doc)
- Rest API Transaction Monitor - site24x7_rest_api_transaction_monitor (Site24x7 Rest API Transaction Monitor API doc)
- Domain Expiry Monitor - site24x7_domain_expiry_monitor(Site24x7 domain expiry monitor API doc)
- Web Transaction Browser Monitor - site24x7_web_transaction_browser_monitor(Site24x7 web transaction browser monitor API doc)
- FTP Transfer Monitor - site24x7_ftp_transfer_monitor(Site24x7 FTP transfer monitor API doc)
- ISP Monitor - site24x7_isp_monitor(Site24x7 ISP monitor API doc)
- Port Monitor - site24x7_port_monitor(Site24x7 port monitor API doc)
- PING Monitor - site24x7_ping_monitor(Site24x7 PING monitor API doc)
- Server Monitor - site24x7_server_monitor (Terraform Server Monitor doc)
- Heartbeat Monitor - site24x7_heartbeat_monitor (Site24x7 Heartbeat Monitor API doc)
- URL IT Automation - site24x7_url_action (Site24x7 IT Automation API doc)
- Monitor Group - site24x7_monitor_group (Site24x7 Monitor Group API doc)
- Threshold Profile - site24x7_threshold_profile (Site24x7 Threshold Profile API doc)
- Location Profile - site24x7_location_profile (Site24x7 Location Profile API doc)
- Notification Profile - site24x7_notification_profile (Site24x7 Notification Profile API doc)
- User Group - site24x7_user_group (Site24x7 User Group API doc)
- User - site24x7_user (Site24x7 User API doc)
- Tag - site24x7_tag (Site24x7 Tag API doc)
- Schedule Maintenance - site24x7_schedule_maintenance (Site24x7 Schedule Maintenance API doc)
- Credential Profile - site24x7_credential_profile (Credential Profile API doc)
- Opsgenie integration - site24x7_opsgenie_integration (Site24x7 Opsgenie integration API doc)
- PagerDuty integration - site24x7_pagerduty_integration (Site24x7 PagerDuty integration API doc)
- ServiceNow integration - site24x7_servicenow_integration (Site24x7 ServiceNow integration API doc)
- Slack integration - site24x7_slack_integration (Site24x7 Slack integration API doc)
- Webhook integration - site24x7_webhook_integration (Site24x7 Webhook integration API doc)
- Connectwise integration - site24x7_connectwise_integration (Site24x7 Connectwise integration API doc)
- Telegram integration - site24x7_telegram_integration (Site24x7 telegram integration API doc)
- Site24x7 monitor - site24x7_monitor/site24x7_monitors (Site24x7 monitor API doc)
- Monitor group - site24x7_monitor_group (Monitor group API doc)
- User group - site24x7_user_group (User group API doc)
- Location profile - site24x7_location_profile (Location profile API doc)
- Threshold profile - site24x7_threshold_profile (Threshold profile API doc)
- Notification profile - site24x7_notification_profile (Notification profile API doc)
- IT automation - site24x7_it_automation (IT automation API doc)
- Tag - site24x7_tag (Tag API doc)
- MSP - site24x7_msp (MSP API doc)
- AWS External ID - site24x7_aws_external_id (AWS External ID Terraform doc)
- Device Key - site24x7_device_key (Device Key Terraform doc)
- Credential Profile - site24x7_credential_profile (Credential Profile Terraform doc)
Refer to the examples/ directory for a fully documented usage example.
Set your Site24x7 OAuth credentials in the bash environment
$ export SITE24X7_OAUTH2_CLIENT_ID="<your_oauth2_client_id>"
$ export SITE24X7_OAUTH2_CLIENT_SECRET="<your_oauth2_client_secret>"
$ export SITE24X7_OAUTH2_REFRESH_TOKEN="<your_oauth2_refresh_token>"
This is a quick example of the provider configuration:
// Authentication API doc - https://www.site24x7.com/help/api/#authentication
provider "site24x7" {
// (Required) The client ID will be looked up in the SITE24X7_OAUTH2_CLIENT_ID
// environment variable if the attribute is empty or omitted.
oauth2_client_id = "<SITE24X7_OAUTH2_CLIENT_ID>"
// (Required) The client secret will be looked up in the SITE24X7_OAUTH2_CLIENT_SECRET
// environment variable if the attribute is empty or omitted.
oauth2_client_secret = "<SITE24X7_OAUTH2_CLIENT_SECRET>"
// (Required) The refresh token will be looked up in the SITE24X7_OAUTH2_REFRESH_TOKEN
// environment variable if the attribute is empty or omitted.
oauth2_refresh_token = "<SITE24X7_OAUTH2_REFRESH_TOKEN>"
// (Required) Specify the data center from which you have obtained your
// OAuth client credentials and refresh token. It can be (US/EU/IN/AU/CN/JP/CA).
data_center = "US"
// (Optional) The access token will be looked up in the SITE24X7_OAUTH2_ACCESS_TOKEN
// environment variable if the attribute is empty or omitted. You need not configure oauth2_access_token
// when oauth2_refresh_token is set.
# oauth2_access_token = "<SITE24X7_OAUTH2_ACCESS_TOKEN>"
// (Optional) oauth2_access_token expiry in seconds. Specify access_token_expiry when oauth2_access_token is configured.
# access_token_expiry = "0"
// (Optional) ZAAID of the customer under a MSP or BU
# zaaid = "1234"
// (Optional) The minimum time to wait in seconds before retrying failed Site24x7 API requests.
retry_min_wait = 1
// (Optional) The maximum time to wait in seconds before retrying failed Site24x7 API
// requests. This is the upper limit for the wait duration with exponential
// backoff.
retry_max_wait = 30
// (Optional) Maximum number of Site24x7 API request retries to perform until giving up.
max_retries = 4
}
// Website Monitor API doc: https://www.site24x7.com/help/api/#website
resource "site24x7_website_monitor" "website_monitor_us" {
// (Required) Name of the monitor
display_name = "Example Monitor"
// (Required) Website address to monitor.
website = "https://www.example.com"
// (Optional) Check interval for monitoring. Default: 1. See
// https://www.site24x7.com/help/api/#check-interval for all supported
// values.
check_frequency = "1"
}
Site24x7 REST APIs uses the OAuth 2.0 protocol to authorize and authenticate calls. To generate Site24x7 OAuth credentials(SITE24X7_OAUTH2_CLIENT_ID
, SITE24X7_OAUTH2_CLIENT_SECRET
and SITE24X7_OAUTH2_REFRESH_TOKEN
) please follow the steps below
- Visit https://api-console.zoho.com/
- Choose the self client option.
- Copy the Client ID, Client Secret and paste them in the below curl command.
- Copy and paste
Site24x7.account.All,Site24x7.admin.All,Site24x7.reports.All,Site24x7.operations.All,Site24x7.msp.All,Site24x7.bu.All
in the scope field and click the "Create" button. - Copy the generated code, paste it in the below command and execute the same.
curl https://accounts.zoho.com/oauth/v2/token
-X POST
-d "client_id=<CLIENT_ID>"
-d "client_secret=<CLIENT_SECRET>"
-d "code=<GENERATED_CODE>"
-d "grant_type=authorization_code" --insecure
- The response for the above command will be similar to the one given below.
{"access_token":"1000.dfsewerwe33.rterert23","refresh_token":"1000.abdfdf.32dsfsdf","token_type":"Bearer","expires_in":3600}
- Copy the the
CLIENT_ID
,CLIENT_SECRET
,refresh_token
and configure them in your terraform configuration file for the attributesoauth2_client_id
,oauth2_client_secret
,oauth2_refresh_token
respectively.
Note: Domain names in the OAuth credentials generation steps vary based on your data center
- United States (US) - https://accounts.zoho.com and https://api-console.zoho.com
- Europe (EU) - https://accounts.zoho.eu and https://api-console.zoho.eu
- China (CN) - https://accounts.zoho.com.cn and https://api-console.zoho.com.cn
- Japan (JP) - https://accounts.zoho.jp and https://api-console.zoho.jp
- India (IN) - https://accounts.zoho.in and https://api-console.zoho.in
- Australia (AU) - https://accounts.zoho.com.au and https://api-console.zoho.com.au
- Canada (CA) - https://accounts.zohocloud.ca and https://api-console.zohocloud.ca
Execute the below command to clone Site24x7's terraform provider repository to any desired location in your file system.
git clone https://github.com/site24x7/terraform-provider-site24x7.git
cd terraform-provider-site24x7
The current directory denotes your $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME
$ export SITE24X7_OAUTH2_CLIENT_ID="<your_oauth2_client_id>"
$ export SITE24X7_OAUTH2_CLIENT_SECRET="<your_oauth2_client_secret>"
$ export SITE24X7_OAUTH2_REFRESH_TOKEN="<your_oauth2_refresh_token>"
To fetch all the server monitor IDs using the datasource site24x7_monitors
paste the below configuration in $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME/main.tf
// Data source to fetch all SERVER monitors
data "site24x7_monitors" "s247monitors" {
// (Optional) Type of the monitor. (eg) RESTAPI, SSL_CERT, URL, SERVER etc.
monitor_type = "SERVER"
}
resource "local_file" "key" {
filename = "${path.module}/utilities/importer/monitors_to_import.json"
content = jsonencode(data.site24x7_monitors.s247monitors.ids)
}
Execute the below commands to write all the server monitor IDs in the file $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME/utilities/importer/monitors_to_import.json
cd $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME
terraform init
terraform apply
Execute the below commands to generate empty configuration, terraform import commands and the state file configuration.
cd utilities/importer
terraform init
python site24x7_importer.py --resource site24x7_server_monitor
Copy the empty configurations(similar to the one given below) generated in the file $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME/empty_configuration.tf
to your terraform configuration file.
resource "site24x7_server_monitor" "SERVER_123456000025786003" {
}
resource "site24x7_server_monitor" "SERVER_123456000027570003" {
}
Copy $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME/utilities/importer/output/import_commands.sh
to your terraform directory and execute the same to import all the monitors to your terraform state.
./import_commands.sh
Copy the resource configurations(similar to the one given below) generated in the file $SITE24X7_TERRAFORM_PROVIDER_REPOSITORY_HOME/utilities/importer/output/imported_configuration.tf
to your terraform configuration file.
resource "site24x7_server_monitor" "SERVER_123456000025786003" {
perform_automation = true
log_needed = true
notification_profile_id = "123456000000029001"
tag_ids = ["123456000024829001", "123456000024829005"]
poll_interval = 1
monitor_groups = ["123456000000120011"]
threshold_profile_id = "123456000000029003"
user_group_ids = ["123456000000025005", "123456000000025009"]
display_name = "ubuntu-server"
}
If you wish to work on the provider, you'll first need Go installed on your
machine (version 1.13+ is required). You'll also need to correctly setup a
GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
Clone the repository and build the provider:
git clone https://github.com/site24x7/terraform-provider-site24x7.git
cd terraform-provider-site24x7
./build/build_terraform_provider_site24x7.sh
This will build the terraform-provider-site24x7
binary and install it into
the $HOME/.terraform.d/plugins/registry.terraform.io/site24x7/1.0.0/linux_amd64
directory.
Place the below content in ~/.terraformrc
provider_installation {
filesystem_mirror {
path = "$HOME/.terraform.d/plugins"
include = ["registry.terraform.io/site24x7/*"]
}
}
Please refer the following links for installing custom providers.
We'll aim to support the latest supported release of Go, along with the previous release. This doesn't mean that building with an older version of Go will not work, but we don't intend to support a Go version in this project that is not supported by the larger Go community. Please see the Go releases page for more details.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Even the tiniest contributions to the script or to the documentation are very welcome and greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b <branch name>
) - Commit your Changes (
git commit -m '<commit message>'
) - Push to the Branch (
git push origin <branch name>
) - Open a Pull Request
Copyright (c) 2024 Zoho Corporation Private Limited
This project is licensed under the MIT License - see LICENSE file for details.
The Site24x7 Terraform Provider uses code from the following library:
- Bonial.com, MIT License