Skip to content

unassign_private_nat_gateway_address async

unassign_private_nat_gateway_address(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    nat_gateway_id: Optional[NatGatewayId] = None,
    private_ip_addresses: Optional[IpList] = None,
    max_drain_duration_seconds: Optional[DrainSeconds] = None,
    dry_run: Optional[Boolean] = None,
) -> UnassignPrivateNatGatewayAddressResult

Unassigns secondary private IPv4 addresses from a private NAT gateway. You cannot unassign your primary private IP. For more information, see Edit secondary IP address associations in the Amazon VPC User Guide.

While unassigning is in progress, you cannot assign/unassign additional IP addresses while the connections are being drained. You are, however, allowed to delete the NAT gateway.

A private IP address will only be released at the end of MaxDrainDurationSeconds. The private IP addresses stay associated and support the existing connections, but do not support any new connections (new connections are distributed across the remaining assigned private IP address). After the existing connections drain out, the private IP addresses are released.

Parameters:

  • nat_gateway_id (Optional[NatGatewayId], default: None ) –

    The ID of the NAT gateway.

  • private_ip_addresses (Optional[IpList], default: None ) –

    The private IPv4 addresses you want to unassign.

  • max_drain_duration_seconds (Optional[DrainSeconds], default: None ) –

    The maximum amount of time to wait (in seconds) before forcibly releasing the IP addresses if connections are still in progress. Default value is 350 seconds.

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

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def unassign_private_nat_gateway_address(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    nat_gateway_id: Optional["capo_ec2.types.nat_gateway_id.NatGatewayId"] = None,
    private_ip_addresses: Optional["capo_ec2.types.ip_list.IpList"] = None,
    max_drain_duration_seconds: Optional[
        "capo_ec2.types.drain_seconds.DrainSeconds"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.unassign_private_nat_gateway_address_result.UnassignPrivateNatGatewayAddressResult":
    """<p>Unassigns secondary private IPv4 addresses from a private NAT gateway. You cannot unassign your primary private IP. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/nat-gateway-working-with.html#nat-gateway-edit-secondary">Edit secondary IP address associations</a> in the <i>Amazon VPC User Guide</i>.</p> <p>While unassigning is in progress, you cannot assign/unassign additional IP addresses while the connections are being drained. You are, however, allowed to delete the NAT gateway.</p> <p>A private IP address will only be released at the end of MaxDrainDurationSeconds. The private IP addresses stay associated and support the existing connections, but do not support any new connections (new connections are distributed across the remaining assigned private IP address). After the existing connections drain out, the private IP addresses are released.</p> <p></p> <p></p>

    Args:
        nat_gateway_id: <p>The ID of the NAT gateway.</p>
        private_ip_addresses: <p>The private IPv4 addresses you want to unassign.</p>
        max_drain_duration_seconds: <p>The maximum amount of time to wait (in seconds) before forcibly releasing the IP addresses if connections are still in progress. Default value is 350 seconds.</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>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.unassign_private_nat_gateway_address_request.UnassignPrivateNatGatewayAddressRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.unassign_private_nat_gateway_address_result.UnassignPrivateNatGatewayAddressResult"
    ]:
        import capo_ec2._operations.amazon_ec2.unassign_private_nat_gateway_address

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UnassignPrivateNatGatewayAddress")
    )
    input_: capo_ec2.types.unassign_private_nat_gateway_address_request.UnassignPrivateNatGatewayAddressRequest = {}
    if nat_gateway_id is not None:
        input_["nat_gateway_id"] = nat_gateway_id
    if private_ip_addresses is not None:
        input_["private_ip_addresses"] = private_ip_addresses
    if max_drain_duration_seconds is not None:
        input_["max_drain_duration_seconds"] = max_drain_duration_seconds
    if dry_run is not None:
        input_["dry_run"] = dry_run

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