Skip to content

associate_client_vpn_target_network async

associate_client_vpn_target_network(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_vpn_endpoint_id: Optional[ClientVpnEndpointId] = None,
    subnet_id: Optional[SubnetId] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    availability_zone: Optional[AvailabilityZoneName] = None,
    availability_zone_id: Optional[AvailabilityZoneId] = None,
) -> AssociateClientVpnTargetNetworkResult

Associates a target network with a Client VPN endpoint. A target network is a subnet in a VPC. You can associate multiple subnets from the same VPC with a Client VPN endpoint. You can associate only one subnet in each Availability Zone. We recommend that you associate at least two subnets to provide Availability Zone redundancy.

If you specified a VPC when you created the Client VPN endpoint or if you have previous subnet associations, the specified subnet must be in the same VPC. To specify a subnet that's in a different VPC, you must first modify the Client VPN endpoint (ModifyClientVpnEndpoint) and change the VPC that's associated with it.

Parameters:

  • client_vpn_endpoint_id (Optional[ClientVpnEndpointId], default: None ) –

    The ID of the Client VPN endpoint.

  • subnet_id (Optional[SubnetId], default: None ) –

    The ID of the subnet to associate with the Client VPN endpoint. Required for VPC-based endpoints. For Transit Gateway-based endpoints, use AvailabilityZone or AvailabilityZoneId instead.

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

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

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

  • availability_zone (Optional[AvailabilityZoneName], default: None ) –

    The Availability Zone name for the Transit Gateway association. Required if when associating an Availability Zone with a Client VPN endpoint that uses a Transit Gateway. You cannot specify both SubnetId and AvailabilityZone.

  • availability_zone_id (Optional[AvailabilityZoneId], default: None ) –

    The Availability Zone ID for the Transit Gateway association. Required if when associating an Availability Zone with a Client VPN endpoint that uses a Transit Gateway. You cannot specify both AvailabilityZone and AvailabilityZoneId.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def associate_client_vpn_target_network(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_vpn_endpoint_id: Optional[
        "capo_ec2.types.client_vpn_endpoint_id.ClientVpnEndpointId"
    ] = None,
    subnet_id: Optional["capo_ec2.types.subnet_id.SubnetId"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    availability_zone: Optional[
        "capo_ec2.types.availability_zone_name.AvailabilityZoneName"
    ] = None,
    availability_zone_id: Optional[
        "capo_ec2.types.availability_zone_id.AvailabilityZoneId"
    ] = None,
) -> "capo_ec2.types.associate_client_vpn_target_network_result.AssociateClientVpnTargetNetworkResult":
    """<p>Associates a target network with a Client VPN endpoint. A target network is a subnet in a VPC. You can associate multiple subnets from the same VPC with a Client VPN endpoint. You can associate only one subnet in each Availability Zone. We recommend that you associate at least two subnets to provide Availability Zone redundancy.</p> <p>If you specified a VPC when you created the Client VPN endpoint or if you have previous subnet associations, the specified subnet must be in the same VPC. To specify a subnet that's in a different VPC, you must first modify the Client VPN endpoint (<a>ModifyClientVpnEndpoint</a>) and change the VPC that's associated with it.</p>

    Args:
        client_vpn_endpoint_id: <p>The ID of the Client VPN endpoint.</p>
        subnet_id: <p>The ID of the subnet to associate with the Client VPN endpoint. Required for VPC-based endpoints. For Transit Gateway-based endpoints, use <code>AvailabilityZone</code> or <code>AvailabilityZoneId</code> instead.</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">Ensuring idempotency</a>.</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>
        availability_zone: <p>The Availability Zone name for the Transit Gateway association. Required if when associating an Availability Zone with a Client VPN endpoint that uses a Transit Gateway. You cannot specify both <code>SubnetId</code> and <code>AvailabilityZone</code>.</p>
        availability_zone_id: <p>The Availability Zone ID for the Transit Gateway association. Required if when associating an Availability Zone with a Client VPN endpoint that uses a Transit Gateway. You cannot specify both <code>AvailabilityZone</code> and <code>AvailabilityZoneId</code>.</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.associate_client_vpn_target_network_request.AssociateClientVpnTargetNetworkRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.associate_client_vpn_target_network_result.AssociateClientVpnTargetNetworkResult"
    ]:
        import capo_ec2._operations.amazon_ec2.associate_client_vpn_target_network

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateClientVpnTargetNetwork")
    )
    input_: capo_ec2.types.associate_client_vpn_target_network_request.AssociateClientVpnTargetNetworkRequest = {}
    if client_vpn_endpoint_id is not None:
        input_["client_vpn_endpoint_id"] = client_vpn_endpoint_id
    if subnet_id is not None:
        input_["subnet_id"] = subnet_id
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if availability_zone is not None:
        input_["availability_zone"] = availability_zone
    if availability_zone_id is not None:
        input_["availability_zone_id"] = availability_zone_id

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