All Products
Search
Document Center

Edge Security Acceleration:Configure site development mode using Terraform

Last Updated:Jun 17, 2026

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.

  • 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.

Important

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

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 the provider and Terraform version

First, create a configuration file named providers.tf. Copy the following code into the file to manage all provider configurations and version constraints.

terraform {
  required_providers {
    alicloud = {
      source  = "aliyun/alicloud"
      version = "1.266.0"
    }
  }
}

provider "alicloud" {
  region = "ap-southeast-1"
}

Define resources

  1. 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  = "basicplan_intl"     # 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.
    }
  2. Navigate to the directory that contains your configuration files and run the following command to initialize the Terraform environment.

    terraform init
  3. Run the following command to validate the Terraform syntax and configuration.

    terraform validate
  4. Run the following command to preview the execution plan.

    terraform plan
  5. Run the following command to apply the configuration.

    terraform apply
  6. When prompted, enter yes to confirm and apply the changes.

Verify Results

Run the terraform show Command

In the working directory, use the following command to query the details of resources created by Terraform:

terraform show

Log on to the Console to View

  1. In the ESA console, select Site Management. In the Website column, click the target site.

  2. In the navigation pane on the left, select Caching > Settings.

  3. On the Settings page, view the details of the newly created cache configuration.

(Optional) Clean up resources

When you no longer need these resources, run the terraform destroy command.

terraform destroy

Related references

Site plan types

The following table describes the valid values for the plan_name parameter in the alicloud_esa_rate_plan_instance resource.

Parameter value

Plan name

Description

entranceplan_intl

Entrance

Suitable for testing and small-scale business scenarios. Provides basic acceleration and security features.

basicplan_intl

Pro

The recommended configuration for small and medium-sized enterprise websites and applications.

vipplan_intl

Enterprise

Suitable for medium and large-sized enterprises. Provides higher performance and enhanced security.

Parameter description

The following table describes valid values for the development_mode field in the Terraform alicloud_esa_site resource.

Value

Function

Description

on

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.

off

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.

Warning

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.

FAQ

What to do when "StatusCode400 Code: ConfExceedLimit" occurs during Terraform code execution?

When you configure cache settings in the console, a corresponding rule is automatically generated. However, the Terraform alicloud_esa_cache_rule resource creates rules. Therefore, you cannot directly update existing cache configurations. First, call the ListCacheRules API to get the ConfigId for the current site's cache configuration. Then, call the DeleteCacheRule API to delete the site cache configuration. After that, apply the Terraform code.