All Products
Search
Document Center

Web Application Firewall:CreateDefenseResource

Last Updated:Mar 25, 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

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Resource

string

No

The name of the protected object.

Note
  • Only protected objects of hybrid cloud deployments support custom names.

abctest.com

Product

string

Yes

The name of the Alibaba Cloud service. Valid values:

  • alb: Application Load Balancer (ALB).

  • ecs: Elastic Compute Service (ECS).

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

  • clb7: Layer 7 CLB.

  • 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.

testGroup

ResourceOrigin

string

Yes

The origin type of the protected object. Valid values:

  • custom: a user-defined protected object.

custom

Pattern

string

Yes

The type of the protected object. Valid values:

  • domain: domain name.

  • multi_service: hybrid cloud deployment.

domain

Detail

string

Yes

The configuration details of the protected object, in JSON format.

Note

The required parameters vary based on the values of Product and Pattern. For more information, see the Description of the Detail parameter section.

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

XffStatus

integer

No

Indicates whether the X-Forwarded-For (XFF) proxy feature is enabled. Valid values:

  • 0 (default): disabled.

  • 1: enabled.

0

CustomHeaders

array

No

The custom header fields used to obtain the actual client IP address when XFF proxy is enabled.

Note

If XffStatus is set to 1, WAF uses the first IP address from the specified header field as the client IP address to prevent XFF forgery. If you specify multiple header fields, WAF reads them in order. If no valid client IP address is found in the specified header fields, WAF falls back to the first IP address in the X-Forwarded-For header field.

string

No

The name of a custom header field from which WAF extracts the client IP address.

x-forwarded-for

Description

string

No

The description of the protected object.

test

InstanceId

string

Yes

The ID of the WAF instance.

Note

Call DescribeInstance to query the ID of the WAF instance.

waf_v3prepaid_public_cn-4xl*******

OwnerUserId

string

No

The ID of the Alibaba Cloud account to which the protected object belongs. This parameter is required only in multi-account scenarios. By default, the protected object belongs to the WAF administrator account.

123221XXX

Tag

array<object>

No

A list of tags. You can add up to 20 tags.

object

No

The tag object.

Key

string

No

The key of the tag.

demoTagKey

Value

string

No

The value of the tag.

TagValue1

ResourceManagerResourceGroupId

string

No

The ID of the Alibaba Cloud resource group.

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

Description of the Detail parameter

ALB domain name (Product is set to alb and Pattern is set to domain)

Adds a protected object for the domain name of an Application Load Balancer (ALB) instance protected by WAF.

Parameters

Name Type Required Example Description
instanceId String Yes alb-cj3w3********1x The ID of the ALB instance that is protected by WAF.
domain String Yes alb.test.com The domain name that you want to add to WAF for protection.

Sample request

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

ECS domain name (Product is set to ecs and Pattern is set to domain)

Adds a protected object for the domain name of an Elastic Compute Service (ECS) instance protected by WAF.

Parameters

Name Type Required Example Description
domain String Yes ecs.test.com The domain name that you want to add to WAF for protection.

Sample request

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

CLB domain name (Product is set to clb4 or clb7 and Pattern is set to domain)

Adds a protected object for the domain name of a Classic Load Balancer (CLB) instance protected by WAF.

Parameters

Name Type Required Example Description
domain String Yes clb.test.com The domain name that you want to add to WAF for protection.

Sample request

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

NLB domain name (Product is set to nlb and Pattern is set to domain)

Adds a protected object for the domain name of a Network Load Balancer (NLB) instance protected by WAF.

Parameters

Name Type Required Example Description
domain String Yes nlb.test.com The domain name that you want to add to WAF for protection.

Sample request

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

WAF hybrid cloud deployment (Product is set to waf and Pattern is set to multi_service)

Creates a protected object for a URL path of a domain name in a hybrid cloud WAF cluster.

Parameters

Name Type Required Example Description
domain String Yes a.test.com The domain name or IP address that you want to add to WAF for protection.
url String Yes /abc The URL path.

Sample request

{
    "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 protected object that is created.

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.