Skip to content

disassociate_address async

disassociate_address(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    association_id: Optional[ElasticIpAssociationId] = None,
    public_ip: Optional[EipAllocationPublicIp] = None,
    dry_run: Optional[Boolean] = None,
) -> None

Disassociates an Elastic IP address from the instance or network interface it's associated with.

This is an idempotent operation. If you perform the operation more than once, Amazon EC2 doesn't return an error.

An address cannot be disassociated if the all of the following conditions are met:

  • Network interface has a publicDualStackDnsName publicDnsName

  • Public IPv4 address is the primary public IPv4 address

  • Network interface only has one remaining public IPv4 address

Parameters:

  • association_id (Optional[ElasticIpAssociationId], default: None ) –

    The association ID. This parameter is required.

  • public_ip (Optional[EipAllocationPublicIp], default: None ) –

    Deprecated.

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

Examples:

To disassociate an Elastic IP address This example disassociates an Elastic IP address from an instance.

>>> await client.disassociate_address(association_id='eipassoc-2bebb745')
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def disassociate_address(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    association_id: Optional[
        "capo_ec2.types.elastic_ip_association_id.ElasticIpAssociationId"
    ] = None,
    public_ip: Optional[
        "capo_ec2.types.eip_allocation_public_ip.EipAllocationPublicIp"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> None:
    """<p>Disassociates an Elastic IP address from the instance or network interface it's associated with.</p> <p>This is an idempotent operation. If you perform the operation more than once, Amazon EC2 doesn't return an error.</p> <p>An address cannot be disassociated if the all of the following conditions are met:</p> <ul> <li> <p>Network interface has a <code>publicDualStackDnsName</code> publicDnsName</p> </li> <li> <p>Public IPv4 address is the primary public IPv4 address</p> </li> <li> <p>Network interface only has one remaining public IPv4 address</p> </li> </ul>

    Args:
        association_id: <p>The association ID. This parameter is required.</p>
        public_ip: <p>Deprecated.</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.

    Examples:
        To disassociate an Elastic IP address
        This example disassociates an Elastic IP address from an instance.

        >>> await client.disassociate_address(association_id='eipassoc-2bebb745')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.disassociate_address_request.DisassociateAddressRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_ec2._operations.amazon_ec2.disassociate_address

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DisassociateAddress")
    )
    input_: capo_ec2.types.disassociate_address_request.DisassociateAddressRequest = {}
    if association_id is not None:
        input_["association_id"] = association_id
    if public_ip is not None:
        input_["public_ip"] = public_ip
    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