1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. esa
  5. CompressionRule
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.esa.CompressionRule

Explore with Pulumi AI

Provides a ESA Compression Rule resource.

For information about ESA Compression Rule and how to use it, see What is Compression Rule.

NOTE: Available since v1.244.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const _default = alicloud.esa.getSites({
    planSubscribeType: "enterpriseplan",
});
const example = new alicloud.esa.Site("example", {
    siteName: "compression.example.com",
    instanceId: _default.then(_default => _default.sites?.[0]?.instanceId),
    coverage: "domestic",
    accessType: "NS",
});
const defaultCompressionRule = new alicloud.esa.CompressionRule("default", {
    gzip: "off",
    brotli: "off",
    rule: "http.host eq \"video.example.com\"",
    siteVersion: 0,
    ruleName: "rule_example",
    siteId: example.id,
    zstd: "off",
    ruleEnable: "off",
});
Copy
import pulumi
import pulumi_alicloud as alicloud

default = alicloud.esa.get_sites(plan_subscribe_type="enterpriseplan")
example = alicloud.esa.Site("example",
    site_name="compression.example.com",
    instance_id=default.sites[0].instance_id,
    coverage="domestic",
    access_type="NS")
default_compression_rule = alicloud.esa.CompressionRule("default",
    gzip="off",
    brotli="off",
    rule="http.host eq \"video.example.com\"",
    site_version=0,
    rule_name="rule_example",
    site_id=example.id,
    zstd="off",
    rule_enable="off")
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/esa"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_default, err := esa.GetSites(ctx, &esa.GetSitesArgs{
			PlanSubscribeType: pulumi.StringRef("enterpriseplan"),
		}, nil)
		if err != nil {
			return err
		}
		example, err := esa.NewSite(ctx, "example", &esa.SiteArgs{
			SiteName:   pulumi.String("compression.example.com"),
			InstanceId: pulumi.String(_default.Sites[0].InstanceId),
			Coverage:   pulumi.String("domestic"),
			AccessType: pulumi.String("NS"),
		})
		if err != nil {
			return err
		}
		_, err = esa.NewCompressionRule(ctx, "default", &esa.CompressionRuleArgs{
			Gzip:        pulumi.String("off"),
			Brotli:      pulumi.String("off"),
			Rule:        pulumi.String("http.host eq \"video.example.com\""),
			SiteVersion: pulumi.Int(0),
			RuleName:    pulumi.String("rule_example"),
			SiteId:      example.ID(),
			Zstd:        pulumi.String("off"),
			RuleEnable:  pulumi.String("off"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var @default = AliCloud.Esa.GetSites.Invoke(new()
    {
        PlanSubscribeType = "enterpriseplan",
    });

    var example = new AliCloud.Esa.Site("example", new()
    {
        SiteName = "compression.example.com",
        InstanceId = @default.Apply(@default => @default.Apply(getSitesResult => getSitesResult.Sites[0]?.InstanceId)),
        Coverage = "domestic",
        AccessType = "NS",
    });

    var defaultCompressionRule = new AliCloud.Esa.CompressionRule("default", new()
    {
        Gzip = "off",
        Brotli = "off",
        Rule = "http.host eq \"video.example.com\"",
        SiteVersion = 0,
        RuleName = "rule_example",
        SiteId = example.Id,
        Zstd = "off",
        RuleEnable = "off",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.esa.EsaFunctions;
import com.pulumi.alicloud.esa.inputs.GetSitesArgs;
import com.pulumi.alicloud.esa.Site;
import com.pulumi.alicloud.esa.SiteArgs;
import com.pulumi.alicloud.esa.CompressionRule;
import com.pulumi.alicloud.esa.CompressionRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var default = EsaFunctions.getSites(GetSitesArgs.builder()
            .planSubscribeType("enterpriseplan")
            .build());

        var example = new Site("example", SiteArgs.builder()
            .siteName("compression.example.com")
            .instanceId(default_.sites()[0].instanceId())
            .coverage("domestic")
            .accessType("NS")
            .build());

        var defaultCompressionRule = new CompressionRule("defaultCompressionRule", CompressionRuleArgs.builder()
            .gzip("off")
            .brotli("off")
            .rule("http.host eq \"video.example.com\"")
            .siteVersion("0")
            .ruleName("rule_example")
            .siteId(example.id())
            .zstd("off")
            .ruleEnable("off")
            .build());

    }
}
Copy
resources:
  example:
    type: alicloud:esa:Site
    properties:
      siteName: compression.example.com
      instanceId: ${default.sites[0].instanceId}
      coverage: domestic
      accessType: NS
  defaultCompressionRule:
    type: alicloud:esa:CompressionRule
    name: default
    properties:
      gzip: off
      brotli: off
      rule: http.host eq "video.example.com"
      siteVersion: '0'
      ruleName: rule_example
      siteId: ${example.id}
      zstd: off
      ruleEnable: off
variables:
  default:
    fn::invoke:
      function: alicloud:esa:getSites
      arguments:
        planSubscribeType: enterpriseplan
Copy

Create CompressionRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new CompressionRule(name: string, args: CompressionRuleArgs, opts?: CustomResourceOptions);
@overload
def CompressionRule(resource_name: str,
                    args: CompressionRuleArgs,
                    opts: Optional[ResourceOptions] = None)

@overload
def CompressionRule(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    site_id: Optional[int] = None,
                    brotli: Optional[str] = None,
                    gzip: Optional[str] = None,
                    rule: Optional[str] = None,
                    rule_enable: Optional[str] = None,
                    rule_name: Optional[str] = None,
                    site_version: Optional[int] = None,
                    zstd: Optional[str] = None)
func NewCompressionRule(ctx *Context, name string, args CompressionRuleArgs, opts ...ResourceOption) (*CompressionRule, error)
public CompressionRule(string name, CompressionRuleArgs args, CustomResourceOptions? opts = null)
public CompressionRule(String name, CompressionRuleArgs args)
public CompressionRule(String name, CompressionRuleArgs args, CustomResourceOptions options)
type: alicloud:esa:CompressionRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. CompressionRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. CompressionRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. CompressionRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. CompressionRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. CompressionRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var compressionRuleResource = new AliCloud.Esa.CompressionRule("compressionRuleResource", new()
{
    SiteId = 0,
    Brotli = "string",
    Gzip = "string",
    Rule = "string",
    RuleEnable = "string",
    RuleName = "string",
    SiteVersion = 0,
    Zstd = "string",
});
Copy
example, err := esa.NewCompressionRule(ctx, "compressionRuleResource", &esa.CompressionRuleArgs{
	SiteId:      pulumi.Int(0),
	Brotli:      pulumi.String("string"),
	Gzip:        pulumi.String("string"),
	Rule:        pulumi.String("string"),
	RuleEnable:  pulumi.String("string"),
	RuleName:    pulumi.String("string"),
	SiteVersion: pulumi.Int(0),
	Zstd:        pulumi.String("string"),
})
Copy
var compressionRuleResource = new CompressionRule("compressionRuleResource", CompressionRuleArgs.builder()
    .siteId(0)
    .brotli("string")
    .gzip("string")
    .rule("string")
    .ruleEnable("string")
    .ruleName("string")
    .siteVersion(0)
    .zstd("string")
    .build());
Copy
compression_rule_resource = alicloud.esa.CompressionRule("compressionRuleResource",
    site_id=0,
    brotli="string",
    gzip="string",
    rule="string",
    rule_enable="string",
    rule_name="string",
    site_version=0,
    zstd="string")
Copy
const compressionRuleResource = new alicloud.esa.CompressionRule("compressionRuleResource", {
    siteId: 0,
    brotli: "string",
    gzip: "string",
    rule: "string",
    ruleEnable: "string",
    ruleName: "string",
    siteVersion: 0,
    zstd: "string",
});
Copy
type: alicloud:esa:CompressionRule
properties:
    brotli: string
    gzip: string
    rule: string
    ruleEnable: string
    ruleName: string
    siteId: 0
    siteVersion: 0
    zstd: string
Copy

CompressionRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The CompressionRule resource accepts the following input properties:

SiteId
This property is required.
Changes to this property will trigger replacement.
int
The site ID, which can be obtained by calling the ListSites API.
Brotli string
Brotli compression. Value range:
Gzip string
Gzip compression. Value range:
Rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
RuleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
RuleName string
Rule name. When adding global configuration, this parameter does not need to be set.
SiteVersion Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
Zstd string
Zstd compression. Value range:
SiteId
This property is required.
Changes to this property will trigger replacement.
int
The site ID, which can be obtained by calling the ListSites API.
Brotli string
Brotli compression. Value range:
Gzip string
Gzip compression. Value range:
Rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
RuleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
RuleName string
Rule name. When adding global configuration, this parameter does not need to be set.
SiteVersion Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
Zstd string
Zstd compression. Value range:
siteId
This property is required.
Changes to this property will trigger replacement.
Integer
The site ID, which can be obtained by calling the ListSites API.
brotli String
Brotli compression. Value range:
gzip String
Gzip compression. Value range:
rule String
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable String
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName String
Rule name. When adding global configuration, this parameter does not need to be set.
siteVersion Changes to this property will trigger replacement. Integer
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd String
Zstd compression. Value range:
siteId
This property is required.
Changes to this property will trigger replacement.
number
The site ID, which can be obtained by calling the ListSites API.
brotli string
Brotli compression. Value range:
gzip string
Gzip compression. Value range:
rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName string
Rule name. When adding global configuration, this parameter does not need to be set.
siteVersion Changes to this property will trigger replacement. number
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd string
Zstd compression. Value range:
site_id
This property is required.
Changes to this property will trigger replacement.
int
The site ID, which can be obtained by calling the ListSites API.
brotli str
Brotli compression. Value range:
gzip str
Gzip compression. Value range:
rule str
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
rule_enable str
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
rule_name str
Rule name. When adding global configuration, this parameter does not need to be set.
site_version Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd str
Zstd compression. Value range:
siteId
This property is required.
Changes to this property will trigger replacement.
Number
The site ID, which can be obtained by calling the ListSites API.
brotli String
Brotli compression. Value range:
gzip String
Gzip compression. Value range:
rule String
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable String
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName String
Rule name. When adding global configuration, this parameter does not need to be set.
siteVersion Changes to this property will trigger replacement. Number
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd String
Zstd compression. Value range:

Outputs

All input properties are implicitly available as output properties. Additionally, the CompressionRule resource produces the following output properties:

ConfigId int
Config Id
Id string
The provider-assigned unique ID for this managed resource.
ConfigId int
Config Id
Id string
The provider-assigned unique ID for this managed resource.
configId Integer
Config Id
id String
The provider-assigned unique ID for this managed resource.
configId number
Config Id
id string
The provider-assigned unique ID for this managed resource.
config_id int
Config Id
id str
The provider-assigned unique ID for this managed resource.
configId Number
Config Id
id String
The provider-assigned unique ID for this managed resource.

Look up Existing CompressionRule Resource

Get an existing CompressionRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: CompressionRuleState, opts?: CustomResourceOptions): CompressionRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        brotli: Optional[str] = None,
        config_id: Optional[int] = None,
        gzip: Optional[str] = None,
        rule: Optional[str] = None,
        rule_enable: Optional[str] = None,
        rule_name: Optional[str] = None,
        site_id: Optional[int] = None,
        site_version: Optional[int] = None,
        zstd: Optional[str] = None) -> CompressionRule
func GetCompressionRule(ctx *Context, name string, id IDInput, state *CompressionRuleState, opts ...ResourceOption) (*CompressionRule, error)
public static CompressionRule Get(string name, Input<string> id, CompressionRuleState? state, CustomResourceOptions? opts = null)
public static CompressionRule get(String name, Output<String> id, CompressionRuleState state, CustomResourceOptions options)
resources:  _:    type: alicloud:esa:CompressionRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Brotli string
Brotli compression. Value range:
ConfigId int
Config Id
Gzip string
Gzip compression. Value range:
Rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
RuleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
RuleName string
Rule name. When adding global configuration, this parameter does not need to be set.
SiteId Changes to this property will trigger replacement. int
The site ID, which can be obtained by calling the ListSites API.
SiteVersion Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
Zstd string
Zstd compression. Value range:
Brotli string
Brotli compression. Value range:
ConfigId int
Config Id
Gzip string
Gzip compression. Value range:
Rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
RuleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
RuleName string
Rule name. When adding global configuration, this parameter does not need to be set.
SiteId Changes to this property will trigger replacement. int
The site ID, which can be obtained by calling the ListSites API.
SiteVersion Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
Zstd string
Zstd compression. Value range:
brotli String
Brotli compression. Value range:
configId Integer
Config Id
gzip String
Gzip compression. Value range:
rule String
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable String
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName String
Rule name. When adding global configuration, this parameter does not need to be set.
siteId Changes to this property will trigger replacement. Integer
The site ID, which can be obtained by calling the ListSites API.
siteVersion Changes to this property will trigger replacement. Integer
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd String
Zstd compression. Value range:
brotli string
Brotli compression. Value range:
configId number
Config Id
gzip string
Gzip compression. Value range:
rule string
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable string
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName string
Rule name. When adding global configuration, this parameter does not need to be set.
siteId Changes to this property will trigger replacement. number
The site ID, which can be obtained by calling the ListSites API.
siteVersion Changes to this property will trigger replacement. number
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd string
Zstd compression. Value range:
brotli str
Brotli compression. Value range:
config_id int
Config Id
gzip str
Gzip compression. Value range:
rule str
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
rule_enable str
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
rule_name str
Rule name. When adding global configuration, this parameter does not need to be set.
site_id Changes to this property will trigger replacement. int
The site ID, which can be obtained by calling the ListSites API.
site_version Changes to this property will trigger replacement. int
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd str
Zstd compression. Value range:
brotli String
Brotli compression. Value range:
configId Number
Config Id
gzip String
Gzip compression. Value range:
rule String
Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:

  • Match all incoming requests: value set to true
  • Match specified request: Set the value to a custom expression, for example: (http.host eq "video.example.com")
ruleEnable String
Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
ruleName String
Rule name. When adding global configuration, this parameter does not need to be set.
siteId Changes to this property will trigger replacement. Number
The site ID, which can be obtained by calling the ListSites API.
siteVersion Changes to this property will trigger replacement. Number
The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
zstd String
Zstd compression. Value range:

Import

ESA Compression Rule can be imported using the id, e.g.

$ pulumi import alicloud:esa/compressionRule:CompressionRule example <site_id>:<config_id>
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.