All Products
Search
Document Center

Web Application Firewall:CreateDefenseResource

Last Updated:Aug 11, 2026

Creates a protected object.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

yundun-waf:CreateDefenseResource

create

*DefenseResource

acs:yundun-waf:{#regionId}:{#accountId}:defenseresource/*

None None

Request parameters

Parameter

Type

Required

Description

Example

Resource

string

No

The name of the protected object.

Note
  • Only protected objects in hybrid cloud service mode support custom protected object names.

abctest.com

Product

string

Yes

The cloud product name. Valid values:

  • alb: Application Load Balancer (ALB).

  • ecs: Elastic Compute Service (ECS).

  • clb4: Classic Load Balancer (CLB) Layer 4 access.

  • clb7: Classic Load Balancer (CLB) Layer 7 access.

  • nlb: Network Load Balancer (NLB).

  • waf: Web Application Firewall (WAF).

ecs

ResourceGroup

string

No

The name of the protection group to which the protected object is added. This parameter is optional.

testGroup

ResourceOrigin

string

Yes

The source of the protected object. Valid values:

  • custom: user-defined.

custom

Pattern

string

Yes

The protection mode of the protected object. Valid values:

  • domain: domain name-based protection.

  • multi_service: hybrid cloud service-based protection.

Note

Currently, only the following combinations are supported: when Product is set to alb, ecs, clb4, clb7, or nlb, Pattern must be set to domain. When Product is set to waf, Pattern must be set to multi_service.

domain

Detail

string

Yes

The specific parameter information of the protected object, which is a string converted from a JSON object constructed with a series of parameters.

Note

The parameters vary depending on the specified cloud product (Product) and protection mode (Pattern). For more information, see Detail parameter description for protected objects.

Important When Product is set to ecs, clb4, clb7, or nlb, domain names connected to regions in the Chinese mainland must have completed ICP filing.

{\"domain\": \"zhhclb4test096-05111.test.com\"}

XffStatus

integer

No

Specifies whether XFF proxy is enabled for the protected object. Valid values:

  • 0: Disabled (default).

  • 1: Enabled.

0

CustomHeaders

array

No

The list of specified header fields.

Note

When XffStatus is set to 1, the first IP in the specified header field is used as the client source IP to prevent XFF spoofing. When multiple headers are specified, the system attempts to obtain the source IP from each header in order. If the first header does not contain an IP, the system tries the second header, and so on. If no specified header contains an IP, the first IP in the X-Forwarded-For header is used. When XffStatus is set to 1, the IP is obtained from the first available header.

string

No

The specified header field.

x-forwarded-for

Description

string

No

The description of the protected object.

ResourceTest

InstanceId

string

Yes

The ID of the WAF instance.

Note

You can call DescribeInstance to query the ID of the current WAF instance.

waf_v3prepaid_public_cn-4xl*******

OwnerUserId

string

No

The ID of the account to which the protected object belongs in multi-account scenarios. By default, the protected object belongs to the WAF administrator account.

123221XXX

Tag

array<object>

No

The tag list, which contains up to 20 items.

object

No

The resource tag list, which contains up to 20 items.

Key

string

No

The tag key.

demoTagKey

Value

string

No

The tag value.

TagValue1

ResourceManagerResourceGroupId

string

No

The Alibaba Cloud resource group ID.

rg-acfm***q

RegionId

string

No

The region where the WAF instance resides. Valid values:

  • cn-hangzhou: the Chinese mainland.

  • ap-southeast-1: outside the Chinese mainland.

cn-hangzhou

Detail parameter description for protected objects.

ALB Website Config (Product set to alb, Pattern set to domain)

Adds a domain name from an ALB instance that is already connected to WAF as a protected object.

Parameter description

NameTypeRequiredExampleDescription
instanceIdStringYesalb-cj3w3********1xThe instance ID of the ALB instance that is already connected to WAF.
domainStringYesalb.test.comThe domain name to be protected by WAF.

Example

{
    "domain": "alb.test.com",
    "instanceId": "alb-cj3w3********1x"
}

ECS Website Config (Product set to ecs, Pattern set to domain)

Adds a domain name from an ECS instance that is already connected to WAF as a protected object.

Parameter description

NameTypeRequiredExampleDescription
domainStringYesecs.test.comThe domain name to be protected by WAF. The domain name must have completed ICP filing when connected to regions in the Chinese mainland.

Example

{
    "domain": "ecs.test.com"
}

CLB Website Config (Product set to clb4 or clb7, Pattern set to domain)

Adds a domain name from a CLB instance that is already connected to WAF as a protected object.

Parameter description

NameTypeRequiredExampleDescription
domainStringYesclb.test.comThe domain name to be protected by WAF. The domain name must have completed ICP filing when connected to regions in the Chinese mainland.

Example

{
    "domain": "clb.test.com"
}

NLB Website Config (Product set to nlb, Pattern set to domain)

Adds a domain name from an NLB instance that is already connected to WAF as a protected object.

Parameter description

NameTypeRequiredExampleDescription
domainStringYesnlb.test.comThe domain name to be protected by WAF. The domain name must have completed ICP filing when connected to regions in the Chinese mainland.

Example

{
    "domain": "nlb.test.com"
}

WAF hybrid cloud service access (Product set to waf, Pattern set to multi_service)

Creates a protected object for a domain name path in a WAF hybrid cloud service access cluster.

Parameter description

NameTypeRequiredExampleDescription
domainStringYesa.test.comThe domain name or IP address to be protected by WAF.
urlStringYes/abcThe URL path.

Example

{
    "domain": "a.test.com",
    "url": "/abc"
}

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

1738C613-D054-5191-888B-DC0CF4C3A4A0

Resource

string

The name of the created protected object.

cdX.XXX-call.cn-alb

Examples

Success response

JSON format

{
  "RequestId": "1738C613-D054-5191-888B-DC0CF4C3A4A0",
  "Resource": "cdX.XXX-call.cn-alb"
}

Error codes

HTTP status code

Error code

Error message

Description

400 Waf.Pullin.ResourceExsit Access resource already exists, resource:%s. Access resource already exists, existing resource:%s.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.