All Products
Search
Document Center

Edge Security Acceleration:Configure a waiting room with Terraform

Last Updated:Apr 09, 2026

You can use Terraform to quickly configure a waiting room, which protects your origin from traffic surges with a queuing mechanism.

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

Procedure

  1. To configure the waiting room, create a file named main.tf and add the following code:

    # 1. Query for Enterprise ESA instances
    data "alicloud_esa_sites" "default" {
      plan_subscribe_type = "enterpriseplan"  # Filter for Enterprise instances
    }
    
    # 2. Create a site
    resource "alicloud_esa_site" "resource_Site_example" {
      site_name   = "{{DOMAIN}}"  # Replace with your domain name, such as example.com
      instance_id = data.alicloud_esa_sites.default.sites.0.instance_id
      coverage    = "overseas"  # Overseas acceleration
      access_type = "NS"         # NS access mode
    }
    
    # 3. Create a waiting room
    resource "alicloud_esa_waiting_room" "default" {
      site_id                        = alicloud_esa_site.resource_Site_example.id
      waiting_room_name              = "waitingroom_example"  # Waiting room name
      description                    = "example"
      status                         = "off"  # Disabled by default. Must be enabled manually.
      waiting_room_type              = "default"
    
      # Queuing policy configuration
      queuing_method                 = "fifo"  # FIFO queuing method
      session_duration               = "5"    # Session duration (minutes)
      total_active_users             = "300"  # Maximum concurrent users
      new_users_per_minute           = "200"  # Number of new users admitted per minute
    
      # Matching rule: Conditions that trigger queuing
      host_name_and_path {
        domain    = "sub_domain.com"         # Hostname to match
        path      = "/example"                # Path to match
        subdomain = "example_sub_domain.com."  # Subdomain to match
      }
    
      # Page display configuration
      language                       = "zhcn"  # Queuing page language: Simplified Chinese
      custom_page_html               = ""      # An empty value uses the default queuing page
      queuing_status_code            = "200"   # HTTP status code returned during queuing
      cookie_name                    = "__aliwaitingroom_example"  # Cookie name
    
      # Advanced options
      queue_all_enable               = "off"  # Specifies whether to queue all users
      disable_session_renewal_enable = "off"  # Specifies whether to disable session renewal
      json_response_enable           = "off"  # Specifies whether to return a JSON response
    }
    Note

    Replace the placeholders in the code with your actual values. Replace DOMAIN with your domain name, and update the domain and path in the host_name_and_path block to match your queuing conditions. For a description of the parameters, see the References section.

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

Terraform show command

After terraform apply completes, run the following command in your working directory to check the resource status before you clean up the resources:

terraform show

Console verification

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

  2. In the navigation pane on the left, choose Traffic > Waiting Room.

  3. On the waiting room page, view the new waiting room rule and its configuration details, such as waiting room name, status, queuing method, session duration, and concurrency limits.

References

The following table describes the key parameters used in the code example.

Parameter

Example value

Description

plan_subscribe_type

"enterpriseplan"

Filters for Enterprise ESA instances to obtain an available instance ID.

site_name

DOMAIN

The domain name for the site. Replace the placeholder with your domain name, such as example.com.

waiting_room_name

"waitingroom_example"

The name of the waiting room, which is displayed on the console.

status

"off"

The status of the waiting room. Valid values are off (disabled) and on (enabled). It is disabled by default and must be manually enabled to take effect.

queuing_method

"fifo"

The queuing method. fifo indicates FIFO (First-In, First-Out), where users are admitted in the order they arrive.

session_duration

"5"

The duration of a user's session in minutes after being admitted from the queue. During this time, the user can refresh the page without queuing again.

total_active_users

"300"

The maximum number of concurrent users allowed, including those queuing and those already admitted. When this limit is reached, new users are placed in the queue.

new_users_per_minute

"200"

The maximum number of new users admitted from the queue to the origin per minute. This setting acts as a traffic shaping rate to prevent overloading your origin.

host_name_and_path.domain

"sub_domain.com"

The hostname to match. Requests to this hostname trigger the waiting room.

host_name_and_path.path

"/example"

The path to match. Requests to this path trigger the waiting room.

host_name_and_path.subdomain

"example_sub_domain.com."

The subdomain to match. This is an optional parameter for more specific matching.

language

"zhcn"

The language of the queuing page. zhcn specifies Simplified Chinese, and en specifies English.

custom_page_html

""

The HTML for a custom queuing page. If left empty, the default page is used.

queuing_status_code

"200"

The HTTP status code returned when a user is in the queue. Set this to 200 to ensure a smooth front-end queuing experience.

cookie_name

"__aliwaitingroom_example"

The name of the cookie used to identify a user's position in the queue and session status.

queue_all_enable

"off"

Specifies whether to queue all users. off means queuing is triggered only when traffic exceeds the threshold. on means all users must queue.

disable_session_renewal_enable

"off"

Specifies whether to disable session renewal. off allows users to renew their session by refreshing the page. on may cause a user to be re-queued on refresh.

json_response_enable

"off"

Specifies whether to enable a JSON response. off returns an HTML page. on returns queuing information in JSON format, which is suitable for API scenarios.

Availability

Note

The waiting room feature is available on the Premium and Enterprise plans. Some features require Waiting Room Pro, which is available for the Enterprise plan. To enable it, contact us.

Feature

Premium

Enterprise

Basic waiting room features

Supported

Supported

Number of waiting rooms

1

1 by default. Up to 10 with Waiting Room Pro.

Multiple hostnames and paths

Not supported

1 by default. Up to 50 with Waiting Room Pro.

Custom templates

Not supported

Available with Waiting Room Pro.

Disable session renewal

Not supported

Available with Waiting Room Pro.

JSON-friendly response

Not supported

Available with Waiting Room Pro.

Custom queue status code

Supported

Supported

Queuing method

Only FIFO is supported.

FIFO is supported by default. All queuing methods are available with Waiting Room Pro.

Waiting room rules

Not supported

Up to 5 rules with Waiting Room Pro.

Waiting room events

Not supported

Up to 5 events with Waiting Room Pro.

SEO crawler bypass

Supported

Supported