All Products
Search
Document Center

Edge Security Acceleration:Configure site development mode using Terraform

Last Updated:Mar 19, 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 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.

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

  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  = "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.
    }
  2. Navigate to the directory that contains the configuration files. Then, run the following command to initialize the Terraform environment.

    terraform init

    image

  3. Run the following command to validate the syntax and configuration of the Terraform files.

    terraform validate

    If the output is similar to the following figure, the validation is successful.

    image

  4. Run the following command to preview the changes that will be applied.

    terraform plan
  5. Run the following command to execute the Terraform script.

    terraform apply
  6. When prompted, enter yes to 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 show

View in the console

  1. In the ESA console, go to Site Management and click the target site in the Website column.

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

  3. 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 destroy

Related 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

entranceplan_intl

Entrance

Suitable for testing and small-scale business scenarios. Provides basic acceleration and mitigation capabilities.

basicplan_intl

Pro

Recommended configuration. Suitable for websites and applications of small and medium-sized enterprises.

vipplan_intl

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

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 should I do if I get "StatusCode400 Code: ConfExceedLimit" when running Terraform code?

If you configured cache settings in the console, the system automatically creates a corresponding cache rule. Because the Terraform alicloud_esa_cache_rule resource creates new rules rather than updates existing ones, you cannot directly apply Terraform to modify those settings. First, call the ListCacheRules API to retrieve the current cache configuration ID (ConfigId). Then, call the DeleteCacheRule API to delete the existing cache configuration. After that, apply your Terraform code.