Skip to content

create_traffic_mirror_target async

create_traffic_mirror_target(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    network_interface_id: Optional[NetworkInterfaceId] = None,
    network_load_balancer_arn: Optional[String] = None,
    description: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
    client_token: Optional[String] = None,
    gateway_load_balancer_endpoint_id: Optional[VpcEndpointId] = None,
) -> CreateTrafficMirrorTargetResult

Creates a target for your Traffic Mirror session.

A Traffic Mirror target is the destination for mirrored traffic. The Traffic Mirror source and the Traffic Mirror target (monitoring appliances) can be in the same VPC, or in different VPCs connected via VPC peering or a transit gateway.

A Traffic Mirror target can be a network interface, a Network Load Balancer, or a Gateway Load Balancer endpoint.

To use the target in a Traffic Mirror session, use CreateTrafficMirrorSession.

Parameters:

  • network_interface_id (Optional[NetworkInterfaceId], default: None ) –

    The network interface ID that is associated with the target.

  • network_load_balancer_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the Network Load Balancer that is associated with the target.

  • description (Optional[String], default: None ) –

    The description of the Traffic Mirror target.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to assign to the Traffic Mirror target.

  • dry_run (Optional[Boolean], default: 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.

  • client_token (Optional[String], default: None ) –

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

  • gateway_load_balancer_endpoint_id (Optional[VpcEndpointId], default: None ) –

    The ID of the Gateway Load Balancer endpoint.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def create_traffic_mirror_target(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    network_interface_id: Optional[
        "capo_ec2.types.network_interface_id.NetworkInterfaceId"
    ] = None,
    network_load_balancer_arn: Optional["capo_ec2.types.string.String"] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    gateway_load_balancer_endpoint_id: Optional[
        "capo_ec2.types.vpc_endpoint_id.VpcEndpointId"
    ] = None,
) -> "capo_ec2.types.create_traffic_mirror_target_result.CreateTrafficMirrorTargetResult":
    """<p>Creates a target for your Traffic Mirror session.</p> <p>A Traffic Mirror target is the destination for mirrored traffic. The Traffic Mirror source and the Traffic Mirror target (monitoring appliances) can be in the same VPC, or in different VPCs connected via VPC peering or a transit gateway.</p> <p>A Traffic Mirror target can be a network interface, a Network Load Balancer, or a Gateway Load Balancer endpoint.</p> <p>To use the target in a Traffic Mirror session, use <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTrafficMirrorSession.htm">CreateTrafficMirrorSession</a>.</p>

    Args:
        network_interface_id: <p>The network interface ID that is associated with the target.</p>
        network_load_balancer_arn: <p>The Amazon Resource Name (ARN) of the Network Load Balancer that is associated with the target.</p>
        description: <p>The description of the Traffic Mirror target.</p>
        tag_specifications: <p>The tags to assign to the Traffic Mirror target.</p>
        dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">How to ensure idempotency</a>.</p>
        gateway_load_balancer_endpoint_id: <p>The ID of the Gateway Load Balancer endpoint.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.create_traffic_mirror_target_request.CreateTrafficMirrorTargetRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.create_traffic_mirror_target_result.CreateTrafficMirrorTargetResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_traffic_mirror_target

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.create_traffic_mirror_target.async_create_traffic_mirror_target(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTrafficMirrorTarget")
    )
    input_: capo_ec2.types.create_traffic_mirror_target_request.CreateTrafficMirrorTargetRequest = {}
    if network_interface_id is not None:
        input_["network_interface_id"] = network_interface_id
    if network_load_balancer_arn is not None:
        input_["network_load_balancer_arn"] = network_load_balancer_arn
    if description is not None:
        input_["description"] = description
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if gateway_load_balancer_endpoint_id is not None:
        input_["gateway_load_balancer_endpoint_id"] = (
            gateway_load_balancer_endpoint_id
        )

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output