Use Terraform to quickly enable development mode for your site. This simplifies debugging and verification of changes to your origin content.
Install Terraform and configure permissions
Install and configure Terraform on your computer
For more information about how to use Terraform on your computer, see Install and configure Terraform.
Create an AccessKey pair for a RAM user. An Alibaba Cloud account has all permissions on resources. If the AccessKey pair of your Alibaba Cloud account is leaked, your resources are exposed to great risks. We recommend that you use the AccessKey pair of a RAM user. For more information, see Create an AccessKey pair.
Create environment variables to store identity credentials.
You can create and view your AccessKey on the AccessKey Management page.
If the environment variables are not configured, identity verification fails when you run the Terraform template.
Use an online service (no installation or permission configuration required)
If you do not want to install Terraform, you can use the online service Cloud Shell.
Alibaba Cloud Cloud Shell is a free operations and maintenance (O&M) product. It is pre-installed with Terraform components and configured with identity credentials. Therefore, you can run Terraform commands directly in Cloud Shell. For more information, see Create resources with Terraform.
When you use Terraform in Cloud Shell, its destroy feature can cause data loss. We recommend that you use Cloud Shell only for simple and quick operations, such as debugging. For more information about the limits, see Limits.
Resources involved
Purchase a site plan: alicloud_esa_rate_plan_instance
Create a site resource: alicloud_esa_site
Generate a random number: random_integer (used to generate a test domain name)
Configure site development mode
Create a working directory. Then, create configuration files in the directory as described below, and adjust the settings in the code to meet your needs.
Define provider and Terraform version
First, create a configuration file named providers.tf. Then, copy the following code into the configuration file to centrally manage all provider configurations and version constraints.
terraform {
required_providers {
alicloud = {
source = "aliyun/alicloud"
version = "1.266.0"
region = "ap-southeast-1"
}
}
}Define resources
Create a configuration file named
main.tf. Then, copy the following code into the file to create a site with development mode enabled.# 1. Purchase a site plan resource "alicloud_esa_rate_plan_instance" "default" { type = "NS" # Site access type: NS (DNS server) or CNAME auto_renew = true # Whether to enable auto-renewal period = "1" # Purchase period (unit: months) coverage = "overseas" # Acceleration region. For more information, see the Metric Description section of this topic. auto_pay = true # Automatic payment plan_name = "basic" # Plan name. For more information, see the Metric Description section of this topic. payment_type = "Subscription" # Payment type } # 2. Generate a random number (to generate a unique test domain name) resource "random_integer" "default" { min = 10000 max = 99999 } # 3. Create a site and enable development mode resource "alicloud_esa_site" "default" { site_name = "bcd${random_integer.default.result}.com" # Site name (domain name). In production environments, replace this with your actual domain name. coverage = "overseas" # Acceleration region access_type = "NS" # Site access type: NS or CNAME instance_id = alicloud_esa_rate_plan_instance.default.id # Plan ID development_mode = "on" # Enable development mode. For more information, see the Metric Description section of this topic. }Navigate to the directory that contains the configuration files. Then, run the following command to initialize the Terraform environment.
terraform init
Run the following command to validate the syntax and configuration of the Terraform files.
terraform validateIf the output is similar to the following figure, the validation is successful.

Run the following command to preview the changes that will be applied.
terraform planRun the following command to execute the Terraform script.
terraform applyWhen prompted, enter
yesto confirm the operation.
Verify results
Run the terraform show command
In your working directory, run the following command to view details about the resources Terraform created:
terraform showView in the console
In the ESA console, go to Site Management and click the target site in the Website column.
In the navigation pane on the left, choose .
On the Settings page, view the details of the newly created cache configuration.
(Optional) Clean up resources
If you no longer need the resources created or managed by Terraform, you can run the terraform destroy command to release the resources.
terraform destroyRelated references
Plan types
The following table describes the valid values for the plan_name field of the alicloud_esa_rate_plan_instance Terraform resource.
Parameter value | Plan name | Description |
| Entrance | Suitable for testing and small-scale business scenarios. Provides basic acceleration and mitigation capabilities. |
| Pro | Recommended configuration. Suitable for websites and applications of small and medium-sized enterprises. |
| Enterprise | Suitable for medium and large enterprises. Provides higher performance and security protection capabilities. |
Parameter description
The following table describes valid values for the development_mode field in the Terraform alicloud_esa_site resource.
Value | Function | Description |
| Enable development mode | Static resource requests bypass the cache component of ESA POPs and directly access the origin server. This is useful for debugging because you can compare the performance of accessing the origin server directly with the performance of accessing cached content. |
| Disable development mode (default) | Static resource requests follow the standard path through edge POP caches and return content based on the cache policy. |
Scenarios
Use development mode in the following scenarios:
Origin content debugging: Enable development mode when you need clients to fetch the latest static resources directly from the origin.
Effect comparison testing: Compare the differences between direct access to the origin server and access through ESA cache.
Quick change validation: After updating origin content, validate changes immediately without waiting for cache expiration or manually refreshing the cache.
Development mode sends all static resource requests directly to the origin. This can increase origin load and response time. Use it only during development and debugging. Always disable it in production environments.