Skip to content

disassociate_nat_gateway_address

disassociate_nat_gateway_address(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    nat_gateway_id: Optional[NatGatewayId] = None,
    association_ids: Optional[EipAssociationIdList] = None,
    max_drain_duration_seconds: Optional[DrainSeconds] = None,
    dry_run: Optional[Boolean] = None,
) -> DisassociateNatGatewayAddressResult

Disassociates secondary Elastic IP addresses (EIPs) from a public NAT gateway. You cannot disassociate your primary EIP. For more information, see Edit secondary IP address associations in the Amazon VPC User Guide.

While disassociating is in progress, you cannot associate/disassociate additional EIPs while the connections are being drained. You are, however, allowed to delete the NAT gateway.

An EIP is released only at the end of MaxDrainDurationSeconds. It stays associated and supports the existing connections but does not support any new connections (new connections are distributed across the remaining associated EIPs). As the existing connections drain out, the EIPs (and the corresponding private IP addresses mapped to them) are released.

Parameters:

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

    The ID of the NAT gateway.

  • association_ids (Optional[EipAssociationIdList], default: None ) –

    The association IDs of EIPs that have been associated with the NAT gateway.

  • 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/ec2.py
def disassociate_nat_gateway_address(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    nat_gateway_id: Optional["capo_ec2.types.nat_gateway_id.NatGatewayId"] = None,
    association_ids: Optional[
        "capo_ec2.types.eip_association_id_list.EipAssociationIdList"
    ] = 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.disassociate_nat_gateway_address_result.DisassociateNatGatewayAddressResult":
    """<p>Disassociates secondary Elastic IP addresses (EIPs) from a public NAT gateway. You cannot disassociate your primary EIP. 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 disassociating is in progress, you cannot associate/disassociate additional EIPs while the connections are being drained. You are, however, allowed to delete the NAT gateway.</p> <p>An EIP is released only at the end of MaxDrainDurationSeconds. It stays associated and supports the existing connections but does not support any new connections (new connections are distributed across the remaining associated EIPs). As the existing connections drain out, the EIPs (and the corresponding private IP addresses mapped to them) are released.</p>

    Args:
        nat_gateway_id: <p>The ID of the NAT gateway.</p>
        association_ids: <p>The association IDs of EIPs that have been associated with the NAT gateway.</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.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.disassociate_nat_gateway_address_request.DisassociateNatGatewayAddressRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.disassociate_nat_gateway_address_result.DisassociateNatGatewayAddressResult"
    ]:
        import capo_ec2._operations.amazon_ec2.disassociate_nat_gateway_address

        output, http_response = (
            capo_ec2._operations.amazon_ec2.disassociate_nat_gateway_address.disassociate_nat_gateway_address(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DisassociateNatGatewayAddress")
    )
    input_: capo_ec2.types.disassociate_nat_gateway_address_request.DisassociateNatGatewayAddressRequest = {}
    if nat_gateway_id is not None:
        input_["nat_gateway_id"] = nat_gateway_id
    if association_ids is not None:
        input_["association_ids"] = association_ids
    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 = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output