published on Tuesday, Apr 28, 2026 by Pulumi
published on Tuesday, Apr 28, 2026 by Pulumi
Provides a ESA Custom Response Code Rule resource.
For information about ESA Custom Response Code Rule and how to use it, see What is Custom Response Code Rule.
NOTE: Available since v1.276.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const resourceRatePlanInstanceCustomResponseCodeRuleExample = new alicloud.esa.RatePlanInstance("resource_RatePlanInstance_CustomResponseCodeRule_example", {
type: "NS",
autoRenew: false,
period: 1,
paymentType: "Subscription",
coverage: "overseas",
autoPay: true,
planName: "basic",
});
const resourceSiteCustomResponseCodeRuleExample = new alicloud.esa.Site("resource_Site_CustomResponseCodeRule_example", {
siteName: "hyhexample.cn",
instanceId: resourceRatePlanInstanceCustomResponseCodeRuleExample.id,
coverage: "overseas",
accessType: "NS",
});
const _default = new alicloud.esa.CustomResponseCodeRule("default", {
pageId: "0",
siteId: resourceSiteCustomResponseCodeRuleExample.id,
returnCode: "400",
ruleEnable: "on",
rule: "(http.host eq \"video.example.com\")",
sequence: 1,
siteVersion: 0,
ruleName: name,
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
resource_rate_plan_instance_custom_response_code_rule_example = alicloud.esa.RatePlanInstance("resource_RatePlanInstance_CustomResponseCodeRule_example",
type="NS",
auto_renew=False,
period=1,
payment_type="Subscription",
coverage="overseas",
auto_pay=True,
plan_name="basic")
resource_site_custom_response_code_rule_example = alicloud.esa.Site("resource_Site_CustomResponseCodeRule_example",
site_name="hyhexample.cn",
instance_id=resource_rate_plan_instance_custom_response_code_rule_example.id,
coverage="overseas",
access_type="NS")
default = alicloud.esa.CustomResponseCodeRule("default",
page_id="0",
site_id=resource_site_custom_response_code_rule_example.id,
return_code="400",
rule_enable="on",
rule="(http.host eq \"video.example.com\")",
sequence=1,
site_version=0,
rule_name=name)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/esa"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
resourceRatePlanInstanceCustomResponseCodeRuleExample, err := esa.NewRatePlanInstance(ctx, "resource_RatePlanInstance_CustomResponseCodeRule_example", &esa.RatePlanInstanceArgs{
Type: pulumi.String("NS"),
AutoRenew: pulumi.Bool(false),
Period: pulumi.Int(1),
PaymentType: pulumi.String("Subscription"),
Coverage: pulumi.String("overseas"),
AutoPay: pulumi.Bool(true),
PlanName: pulumi.String("basic"),
})
if err != nil {
return err
}
resourceSiteCustomResponseCodeRuleExample, err := esa.NewSite(ctx, "resource_Site_CustomResponseCodeRule_example", &esa.SiteArgs{
SiteName: pulumi.String("hyhexample.cn"),
InstanceId: resourceRatePlanInstanceCustomResponseCodeRuleExample.ID(),
Coverage: pulumi.String("overseas"),
AccessType: pulumi.String("NS"),
})
if err != nil {
return err
}
_, err = esa.NewCustomResponseCodeRule(ctx, "default", &esa.CustomResponseCodeRuleArgs{
PageId: pulumi.String("0"),
SiteId: resourceSiteCustomResponseCodeRuleExample.ID(),
ReturnCode: pulumi.String("400"),
RuleEnable: pulumi.String("on"),
Rule: pulumi.String("(http.host eq \"video.example.com\")"),
Sequence: pulumi.Int(1),
SiteVersion: pulumi.Int(0),
RuleName: pulumi.String(pulumi.String(name)),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var resourceRatePlanInstanceCustomResponseCodeRuleExample = new AliCloud.Esa.RatePlanInstance("resource_RatePlanInstance_CustomResponseCodeRule_example", new()
{
Type = "NS",
AutoRenew = false,
Period = 1,
PaymentType = "Subscription",
Coverage = "overseas",
AutoPay = true,
PlanName = "basic",
});
var resourceSiteCustomResponseCodeRuleExample = new AliCloud.Esa.Site("resource_Site_CustomResponseCodeRule_example", new()
{
SiteName = "hyhexample.cn",
InstanceId = resourceRatePlanInstanceCustomResponseCodeRuleExample.Id,
Coverage = "overseas",
AccessType = "NS",
});
var @default = new AliCloud.Esa.CustomResponseCodeRule("default", new()
{
PageId = "0",
SiteId = resourceSiteCustomResponseCodeRuleExample.Id,
ReturnCode = "400",
RuleEnable = "on",
Rule = "(http.host eq \"video.example.com\")",
Sequence = 1,
SiteVersion = 0,
RuleName = name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.esa.RatePlanInstance;
import com.pulumi.alicloud.esa.RatePlanInstanceArgs;
import com.pulumi.alicloud.esa.Site;
import com.pulumi.alicloud.esa.SiteArgs;
import com.pulumi.alicloud.esa.CustomResponseCodeRule;
import com.pulumi.alicloud.esa.CustomResponseCodeRuleArgs;
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 config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var resourceRatePlanInstanceCustomResponseCodeRuleExample = new RatePlanInstance("resourceRatePlanInstanceCustomResponseCodeRuleExample", RatePlanInstanceArgs.builder()
.type("NS")
.autoRenew(false)
.period(1)
.paymentType("Subscription")
.coverage("overseas")
.autoPay(true)
.planName("basic")
.build());
var resourceSiteCustomResponseCodeRuleExample = new Site("resourceSiteCustomResponseCodeRuleExample", SiteArgs.builder()
.siteName("hyhexample.cn")
.instanceId(resourceRatePlanInstanceCustomResponseCodeRuleExample.id())
.coverage("overseas")
.accessType("NS")
.build());
var default_ = new CustomResponseCodeRule("default", CustomResponseCodeRuleArgs.builder()
.pageId("0")
.siteId(resourceSiteCustomResponseCodeRuleExample.id())
.returnCode("400")
.ruleEnable("on")
.rule("(http.host eq \"video.example.com\")")
.sequence(1)
.siteVersion(0)
.ruleName(name)
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
resourceRatePlanInstanceCustomResponseCodeRuleExample:
type: alicloud:esa:RatePlanInstance
name: resource_RatePlanInstance_CustomResponseCodeRule_example
properties:
type: NS
autoRenew: false
period: '1'
paymentType: Subscription
coverage: overseas
autoPay: true
planName: basic
resourceSiteCustomResponseCodeRuleExample:
type: alicloud:esa:Site
name: resource_Site_CustomResponseCodeRule_example
properties:
siteName: hyhexample.cn
instanceId: ${resourceRatePlanInstanceCustomResponseCodeRuleExample.id}
coverage: overseas
accessType: NS
default:
type: alicloud:esa:CustomResponseCodeRule
properties:
pageId: '0'
siteId: ${resourceSiteCustomResponseCodeRuleExample.id}
returnCode: '400'
ruleEnable: on
rule: (http.host eq "video.example.com")
sequence: '1'
siteVersion: '0'
ruleName: ${name}
📚 Need more examples? VIEW MORE EXAMPLES
Create CustomResponseCodeRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CustomResponseCodeRule(name: string, args: CustomResponseCodeRuleArgs, opts?: CustomResourceOptions);@overload
def CustomResponseCodeRule(resource_name: str,
args: CustomResponseCodeRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CustomResponseCodeRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
page_id: Optional[str] = None,
return_code: Optional[str] = None,
site_id: Optional[str] = None,
rule: Optional[str] = None,
rule_enable: Optional[str] = None,
rule_name: Optional[str] = None,
sequence: Optional[int] = None,
site_version: Optional[int] = None)func NewCustomResponseCodeRule(ctx *Context, name string, args CustomResponseCodeRuleArgs, opts ...ResourceOption) (*CustomResponseCodeRule, error)public CustomResponseCodeRule(string name, CustomResponseCodeRuleArgs args, CustomResourceOptions? opts = null)
public CustomResponseCodeRule(String name, CustomResponseCodeRuleArgs args)
public CustomResponseCodeRule(String name, CustomResponseCodeRuleArgs args, CustomResourceOptions options)
type: alicloud:esa:CustomResponseCodeRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args CustomResponseCodeRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args CustomResponseCodeRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args CustomResponseCodeRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CustomResponseCodeRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CustomResponseCodeRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
CustomResponseCodeRule 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 CustomResponseCodeRule resource accepts the following input properties:
- Page
Id string - Response page.
- Return
Code string - The response code.
- Site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- Rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- Rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- Rule
Name string - The rule name.
- Sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- Site
Version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- Page
Id string - Response page.
- Return
Code string - The response code.
- Site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- Rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- Rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- Rule
Name string - The rule name.
- Sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- Site
Version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- page
Id String - Response page.
- return
Code String - The response code.
- site
Id String - The website ID, which can be obtained by calling the ListSites operation.
- rule String
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable String - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name String - The rule name.
- sequence Integer
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Version Integer - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- page
Id string - Response page.
- return
Code string - The response code.
- site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name string - The rule name.
- sequence number
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Version number - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- page_
id str - Response page.
- return_
code str - The response code.
- site_
id str - The website ID, which can be obtained by calling the ListSites operation.
- rule str
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule_
enable str - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule_
name str - The rule name.
- sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site_
version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- page
Id String - Response page.
- return
Code String - The response code.
- site
Id String - The website ID, which can be obtained by calling the ListSites operation.
- rule String
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable String - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name String - The rule name.
- sequence Number
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Version Number - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
Outputs
All input properties are implicitly available as output properties. Additionally, the CustomResponseCodeRule resource produces the following output properties:
Look up Existing CustomResponseCodeRule Resource
Get an existing CustomResponseCodeRule 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?: CustomResponseCodeRuleState, opts?: CustomResourceOptions): CustomResponseCodeRule@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
config_id: Optional[str] = None,
page_id: Optional[str] = None,
return_code: Optional[str] = None,
rule: Optional[str] = None,
rule_enable: Optional[str] = None,
rule_name: Optional[str] = None,
sequence: Optional[int] = None,
site_id: Optional[str] = None,
site_version: Optional[int] = None) -> CustomResponseCodeRulefunc GetCustomResponseCodeRule(ctx *Context, name string, id IDInput, state *CustomResponseCodeRuleState, opts ...ResourceOption) (*CustomResponseCodeRule, error)public static CustomResponseCodeRule Get(string name, Input<string> id, CustomResponseCodeRuleState? state, CustomResourceOptions? opts = null)public static CustomResponseCodeRule get(String name, Output<String> id, CustomResponseCodeRuleState state, CustomResourceOptions options)resources: _: type: alicloud:esa:CustomResponseCodeRule get: id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Config
Id string - The ID of the configuration.
- Page
Id string - Response page.
- Return
Code string - The response code.
- Rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- Rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- Rule
Name string - The rule name.
- Sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- Site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- Site
Version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- Config
Id string - The ID of the configuration.
- Page
Id string - Response page.
- Return
Code string - The response code.
- Rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- Rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- Rule
Name string - The rule name.
- Sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- Site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- Site
Version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- config
Id String - The ID of the configuration.
- page
Id String - Response page.
- return
Code String - The response code.
- rule String
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable String - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name String - The rule name.
- sequence Integer
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Id String - The website ID, which can be obtained by calling the ListSites operation.
- site
Version Integer - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- config
Id string - The ID of the configuration.
- page
Id string - Response page.
- return
Code string - The response code.
- rule string
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable string - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name string - The rule name.
- sequence number
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Id string - The website ID, which can be obtained by calling the ListSites operation.
- site
Version number - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- config_
id str - The ID of the configuration.
- page_
id str - Response page.
- return_
code str - The response code.
- rule str
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule_
enable str - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule_
name str - The rule name.
- sequence int
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site_
id str - The website ID, which can be obtained by calling the ListSites operation.
- site_
version int - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
- config
Id String - The ID of the configuration.
- page
Id String - Response page.
- return
Code String - The response code.
- rule String
- The content of the rule. A conditional expression is used to match a user request. You do not need to set this parameter when you add global configurations. Use cases:
- Match all incoming requests: Set the value to true.
- Set the value to a custom expression, for example, (http.host eq "video.example.com"): Match the specified request.
- rule
Enable String - Specifies whether to enable the rule. Valid values: You do not need to set this parameter when you add global configurations. Valid values:
- on
- off
- rule
Name String - The rule name.
- sequence Number
- The order in which the rule is executed. A smaller value gives priority to the rule.
- site
Id String - The website ID, which can be obtained by calling the ListSites operation.
- site
Version Number - The version number of the website configurations. You can use this parameter to specify a version of your website to apply the feature settings. By default, version 0 is used.
Import
ESA Custom Response Code Rule can be imported using the id, e.g.
$ pulumi import alicloud:esa/customResponseCodeRule:CustomResponseCodeRule example <site_id>:<config_id>
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
alicloudTerraform Provider.
published on Tuesday, Apr 28, 2026 by Pulumi
