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 support@site24x7.com.
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:
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
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.
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
{"access_token":"1000.dfsewerwe33.rterert23","refresh_token":"1000.abdfdf.32dsfsdf","token_type":"Bearer","expires_in":3600}
CLIENT_ID
, CLIENT_SECRET
, refresh_token
and configure them in your terraform configuration file for the attributes oauth2_client_id
, oauth2_client_secret
, oauth2_refresh_token
respectively.Note: Domain names in the OAuth credentials generation steps vary based on your data center
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.
git checkout -b <branch name>
)git commit -m '<commit message>'
)git push origin <branch name>
)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: