All Products
Search
Document Center

Web Application Firewall:CreateDefenseResource

Last Updated:Jan 05, 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 you want to add the protected object. This parameter is optional.

testGroup

ResourceOrigin

string

Yes

The source of the protected object. Only the following value is supported:

  • custom: a custom object.

custom

Pattern

string

Yes

The protection mode of the protected object. Valid values:

  • domain: domain name.

  • multi_service: hybrid cloud deployment.

domain

Detail

string

Yes

The detailed parameters of the protected object. This parameter is a string that consists of a JSON struct.

Note

The 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

Specifies whether to enable the X-Forwarded-For (XFF) proxy. Valid values:

  • 0: disabled. This is the default value.

  • 1: enabled.

0

CustomHeaders

array

No

A list of custom header fields.

Note

If you set XffStatus 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 tries to obtain the client IP address from the header fields in sequence. If WAF fails to obtain the client IP address from the specified header fields, it uses the first IP address in the X-Forwarded-For header field.

string

No

The custom header field.

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 account to which the protected object belongs. This parameter is used 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

A list of tags for the resource. You can add up to 20 tags.

Key

string

No

The tag key.

demoTagKey

Value

string

No

The tag value.

TagValue1

ResourceManagerResourceGroupId

string

No

The ID of the Alibaba Cloud resource group.

rg-acfm***q

RegionId

string

No

The region where the WAF instance is deployed. 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

NameTypeRequiredExampleDescription
instanceIdStringYesalb-cj3w3********1xThe ID of the ALB instance that is protected by WAF.
domainStringYesalb.test.comThe domain name that you want to add to WAF for protection.

Example

{
    "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

NameTypeRequiredExampleDescription
domainStringYesecs.test.comThe domain name that you want to add to WAF for protection.

Example

{
    "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 Server Load Balancer (CLB) instance protected by WAF.

Parameters

NameTypeRequiredExampleDescription
domainStringYesclb.test.comThe domain name that you want to add to WAF for protection.

Example

{
    "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

NameTypeRequiredExampleDescription
domainStringYesnlb.test.comThe domain name that you want to add to WAF for protection.

Example

{
    "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 path of a domain name in a WAF hybrid cloud cluster.

Parameters

NameTypeRequiredExampleDescription
domainStringYesa.test.comThe domain name or IP address that you want to add to WAF for protection.
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 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.