Skip to content

EC2  >  Operations  >  create_traffic_mirror_session

create_traffic_mirror_session

Operation

create_traffic_mirror_session async

create_traffic_mirror_session(input: CreateTrafficMirrorSessionInput, plugins: list[Plugin] | None = None) -> CreateTrafficMirrorSessionOutput

Creates a Traffic Mirror session.

A Traffic Mirror session actively copies packets from a Traffic Mirror source to a Traffic Mirror target. Create a filter, and then assign it to the session to define a subset of the traffic to mirror, for example all TCP traffic.

The Traffic Mirror source and the Traffic Mirror target (monitoring appliances) can be in the same VPC, or in a different VPC connected via VPC peering or a transit gateway.

By default, no traffic is mirrored. Use CreateTrafficMirrorFilter to create filter rules that specify the traffic to mirror.

Parameters:

Name Type Description Default
input CreateTrafficMirrorSessionInput

An instance of CreateTrafficMirrorSessionInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
CreateTrafficMirrorSessionOutput

An instance of CreateTrafficMirrorSessionOutput.

Input

CreateTrafficMirrorSessionInput dataclass

Bases: _SerdeShape

Dataclass for CreateTrafficMirrorSessionInput structure.

Attributes

client_token class-attribute instance-attribute
client_token: str | None = ...

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.

This field is autopopulated if not provided.

description class-attribute instance-attribute
description: str | None = ...

The description of the Traffic Mirror session.

dry_run class-attribute instance-attribute
dry_run: bool | None = ...

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

network_interface_id class-attribute instance-attribute
network_interface_id: str | None = ...

The ID of the source network interface.

packet_length class-attribute instance-attribute
packet_length: int | None = ...

The number of bytes in each packet to mirror. These are bytes after the VXLAN header. Do not specify this parameter when you want to mirror the entire packet. To mirror a subset of the packet, set this to the length (in bytes) that you want to mirror. For example, if you set this value to 100, then the first 100 bytes that meet the filter criteria are copied to the target.

If you do not want to mirror the entire packet, use the PacketLength parameter to specify the number of bytes in each packet to mirror.

For sessions with Network Load Balancer (NLB) Traffic Mirror targets the default PacketLength will be set to 8500. Valid values are 1-8500. Setting a PacketLength greater than 8500 will result in an error response.

session_number class-attribute instance-attribute
session_number: int | None = ...

The session number determines the order in which sessions are evaluated when an interface is used by multiple sessions. The first session with a matching filter is the one that mirrors the packets.

Valid values are 1-32766.

tag_specifications class-attribute instance-attribute
tag_specifications: list[TagSpecification] | None = ...

The tags to assign to a Traffic Mirror session.

traffic_mirror_filter_id class-attribute instance-attribute
traffic_mirror_filter_id: str | None = ...

The ID of the Traffic Mirror filter.

traffic_mirror_target_id class-attribute instance-attribute
traffic_mirror_target_id: str | None = ...

The ID of the Traffic Mirror target.

virtual_network_id class-attribute instance-attribute
virtual_network_id: int | None = ...

The VXLAN ID for the Traffic Mirror session. For more information about the VXLAN protocol, see RFC 7348. If you do not specify a VirtualNetworkId, an account-wide unique ID is chosen at random.

Output

CreateTrafficMirrorSessionOutput dataclass

Bases: _SerdeShape

Dataclass for CreateTrafficMirrorSessionOutput structure.

Attributes

client_token class-attribute instance-attribute
client_token: str | None = ...

Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

traffic_mirror_session class-attribute instance-attribute
traffic_mirror_session: TrafficMirrorSession | None = ...

Information about the Traffic Mirror session.