All Products
Search
Document Center

Edge Security Acceleration:Configure video processing rules using Terraform

Last Updated:Mar 28, 2026

You can use Terraform to quickly enable video seeking for formats such as MP4 and FLV on your site and configure related parameters.

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

Configure video processing rules

  1. Create a configuration file named main.tf and copy the following code into the file. The code creates a video processing rule for your site.

    # 1. Specify the name of the site that you want to configure.
    data "alicloud_esa_sites" "default" {
      site_name = "{{DOMAIN}}"  # Replace {{DOMAIN}} with the domain of a site that has been added to ESA, such as example.com.
    }
    
    # 2. Configure the video processing rule.
    resource "alicloud_esa_video_processing" "default" {
      site_id             = data.alicloud_esa_sites.default.sites[0].site_id  # The ID of the site to configure.
      rule_name           = "example2"  # The name of the rule.
      rule_enable         = "on"  # Enable the rule.
      rule                = "true"  # The matching condition. Set to "true" to match all incoming requests.
      video_seek_enable   = "on"  # Enable video seeking for MP4 and FLV files.
      flv_video_seek_mode = "by_byte"  # The seeking mode for FLV files.
      mp4_seek_start      = "start"  # The custom start parameter for MP4 seeking. Default value: start. Supports letters, numbers, and underscores (_).
      mp4_seek_end        = "end"  # The custom end parameter for MP4 seeking. Default value: end.
      flv_seek_start      = "start"  # The custom start parameter for FLV seeking. Default value: start.
      flv_seek_end        = "end"  # The custom end parameter for FLV seeking. Default value: end.
    }
    
  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 result

terraform show

In your working directory, run the following command to view the details of the resources that Terraform created:

terraform show

(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

References

flv_video_seek_mode

The following table describes the valid values for the flv_video_seek_mode parameter in the alicloud_esa_video_processing resource.

Value

Description

by_byte

Seek by byte

by_time

Seek by time