All Products
Search
Document Center

Virtual Private Cloud:CreateTrafficMirrorFilter

Last Updated:Jun 19, 2026

Calls the CreateTrafficMirrorFilter operation to create a traffic mirror filter.

Operation description

The CreateTrafficMirrorFilter operation is an asynchronous operation. After you send the request, the system returns an instance ID but the traffic mirror filter is not yet created. The creation task is still running in the background. You can call ListTrafficMirrorFilters to query the status of the traffic mirror filter:

  • If the traffic mirror filter is in the Creating state, the traffic mirror filter is being created.

  • If the traffic mirror filter is in the Created state, the traffic mirror filter is created.

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

vpc:CreateTrafficMirrorFilter

create

*TrafficMirrorFilter

acs:vpc:{#regionId}:{#accountId}:trafficmirrorfilter/*

None None

Request parameters

Parameter

Type

Required

Description

Example

TrafficMirrorFilterDescription

string

No

The description of the traffic mirror filter.

The description must be 1 to 256 characters in length and cannot start with http:// or https://.

this is a filter.

TrafficMirrorFilterName

string

No

The name of the traffic mirror filter.

The name must be 1 to 128 characters in length and cannot start with http:// or https://.

abc

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The ClientToken value can contain only ASCII characters.

Note

If you do not specify this parameter, the system uses the value of RequestId as the value of ClientToken. The value of RequestId is different for each API request.

123e4567-e89b-12d3-a456-426655440000

DryRun

boolean

No

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error code is returned. If the request passes the dry run, the error code DryRunOperation is returned.

  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the filter is created.

false

IngressRules

array<object>

No

The information about the inbound rules.

object

No

The information about the inbound rules.

Action

string

Yes

The collection policy of the inbound rule. Valid values:

  • accept: collects network traffic.

  • drop: does not collect network traffic.

accept

SourceCidrBlock

string

No

The source CIDR block of the inbound rule.

10.0.0.0/24

Protocol

string

Yes

The protocol type of the network traffic to be mirrored for the inbound rule. Valid values:

  • ALL: all protocols.

  • ICMP: Internet Control Message Protocol.

  • TCP: Transmission Control Protocol.

  • UDP: User Datagram Protocol.

TCP

IpVersion

string

Yes

The IP version of the instance. Valid values:

  • IPv4: IPv4.

  • IPv6: IPv6.

IPv4

DestinationPortRange

string

No

The destination port range of the inbound rule. Valid values for port numbers: 1 to 65535. Separate the start port and end port with a forward slash (/). Format: 1/200 or 80/80.

Note

If IngressRules.N.Protocol is set to ALL or ICMP, this parameter does not need to be set, which indicates that all ports are available.

80/120

Priority

integer

No

The priority of the inbound rule. A smaller value indicates a higher priority. The maximum value of N is 10, which indicates that a filter can have up to 10 inbound rules.

1

DestinationCidrBlock

string

No

The destination CIDR block of the inbound rule.

10.0.0.0/24

SourcePortRange

string

No

The source port range of the inbound rule. Valid values for port numbers: 1 to 65535. Separate the start port and end port with a forward slash (/). Format: 1/200 or 80/80.

Note

If IngressRules.N.Protocol is set to ALL or ICMP, this parameter does not need to be set, which indicates that all ports are available.

80/120

EgressRules

array<object>

No

The information about the outbound rules.

object

No

The information about the outbound rules.

Action

string

Yes

The collection policy of the outbound rule. Valid values:

  • accept: collects network traffic.

  • drop: does not collect network traffic.

accept

SourceCidrBlock

string

No

The source CIDR block of the outbound rule.

10.0.0.0/24

Protocol

string

Yes

The protocol type of the network traffic to be mirrored for the outbound rule. Valid values:

  • ALL: all protocols.

  • ICMP: Internet Control Message Protocol.

  • TCP: Transmission Control Protocol.

  • UDP: User Datagram Protocol.

TCP

IpVersion

string

Yes

The IP version of the instance. Valid values:

  • IPv4: IPv4.

  • IPv6: IPv6.

IPv4

DestinationPortRange

string

No

The destination port range of the outbound rule. Valid values for port numbers: 1 to 65535. Separate the start port and end port with a forward slash (/). Format: 1/200 or 80/80. The value -1/-1 cannot be set independently and indicates that all ports are available.

Note

If EgressRules.N.Protocol is set to ALL or ICMP, this parameter does not need to be set, which indicates that all ports are available.

22/40

Priority

integer

No

The priority of the outbound rule. A smaller value indicates a higher priority. The maximum value of N is 10, which indicates that a filter can have up to 10 outbound rules.

1

DestinationCidrBlock

string

No

The destination CIDR block of the outbound rule.

10.0.0.0/24

SourcePortRange

string

No

The source port range of the outbound rule. Valid values for port numbers: 1 to 65535. Separate the start port and end port with a forward slash (/). Format: 1/200 or 80/80. The value -1/-1 cannot be set independently and indicates that all ports are available.

Note

If EgressRules.N.Protocol is set to ALL or ICMP, this parameter does not need to be set, which indicates that all ports are available.

22/40

RegionId

string

Yes

The region ID of the traffic mirror.

You can call the DescribeRegions operation to query the region ID. For more information about the regions that support traffic mirroring, see Traffic Mirroring overview.

cn-hongkong

ResourceGroupId

string

No

The ID of the resource group to which the traffic mirror belongs.

rg-bp67acfmxazb4ph****

Tag

array<object>

No

The tags of the resource.

object

No

The tag.

Key

string

No

The tag key of the resource. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

FinanceDept

Value

string

No

The tag value of the resource. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

FinanceJoshua

Response elements

Element

Type

Description

Example

object

The instance ID of the traffic mirror filter.

TrafficMirrorFilterId

string

The instance ID of the traffic mirror filter.

tmf-j6cmls82xnc86vtpe****

RequestId

string

The request ID.

28DB147D-217B-43E8-9E94-A3F6837DDC8A

ResourceGroupId

string

The ID of the resource group to which the traffic mirror belongs.

rg-bp67acfmxazb4ph****

Examples

Success response

JSON format

{
  "TrafficMirrorFilterId": "tmf-j6cmls82xnc86vtpe****",
  "RequestId": "28DB147D-217B-43E8-9E94-A3F6837DDC8A",
  "ResourceGroupId": "rg-bp67acfmxazb4ph****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 UnsupportedFeature.IpVersion The ipversion type is not supported.
400 IncorrectBusinessStatus.TrafficMirror The business status of traffic mirror is incorrect. Traffic mirroring is in an invalid state.
400 OptInRequired.TrafficMirror You need to subscribe to the traffic mirror service first. Traffic mirroring is disabled.
400 QuotaExceeded.TrafficMirrorFilter The maximum number of traffic image filters is exceeded. The number of filters has reached the upper limit.
400 DuplicatedParam.Priority The specified priority conflicts with the existing priority. The specified priority is the same as an existing one.
400 UnsupportedRegion The feature is not supported in current region. The feature is not supported in the current region.
400 IllegalParamFormat.SrcCidrBlock The format of the specified source CIDR block is invalid. The error message returned because the format of the source CIDR block is invalid.
400 IllegalParamFormat.DstCidrBlock The format of the specified dst CIDR block is invalid. The format of the destination CIDR block is invalid.
400 IllegalParam.DestinationCidrBlock The param of DestinationCidrBlock %s is illegal.
400 IllegalParam.SourceCidrBlock The param of SourceCidrBlock %s is illegal.
400 IllegalParam.Protocol The specified Protocol %s is invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.