Skip to content

allocate_address

allocate_address(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    domain: Optional[DomainType] = None,
    address: Optional[PublicIpAddress] = None,
    public_ipv4_pool: Optional[Ipv4PoolEc2Id] = None,
    network_border_group: Optional[String] = None,
    customer_owned_ipv4_pool: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    ipam_pool_id: Optional[IpamPoolId] = None,
    dry_run: Optional[Boolean] = None,
) -> AllocateAddressResult

Allocates an Elastic IP address to your Amazon Web Services account. After you allocate the Elastic IP address you can associate it with an instance or network interface. After you release an Elastic IP address, it is released to the IP address pool and can be allocated to a different Amazon Web Services account.

You can allocate an Elastic IP address from one of the following address pools:

  • Amazon's pool of IPv4 addresses

  • Public IPv4 address range that you own and bring to your Amazon Web Services account using Bring Your Own IP Addresses (BYOIP)

  • An IPv4 IPAM pool with an Amazon-provided or BYOIP public IPv4 address range

  • IPv4 addresses from your on-premises network made available for use with an Outpost using a customer-owned IP address pool (CoIP pool)

For more information, see Elastic IP Addresses in the Amazon EC2 User Guide.

If you release an Elastic IP address, you might be able to recover it. You cannot recover an Elastic IP address that you released after it is allocated to another Amazon Web Services account. To attempt to recover an Elastic IP address that you released, specify it in this operation.

You can allocate a carrier IP address which is a public IP address from a telecommunication carrier, to a network interface which resides in a subnet in a Wavelength Zone (for example an EC2 instance).

Parameters:

  • domain (Optional[DomainType], default: None ) –

    The network (vpc).

  • address (Optional[PublicIpAddress], default: None ) –

    The Elastic IP address to recover or an IPv4 address from an address pool.

  • public_ipv4_pool (Optional[Ipv4PoolEc2Id], default: None ) –

    The ID of an address pool that you own. Use this parameter to let Amazon EC2 select an address from the address pool. To specify a specific address from the address pool, use the Address parameter instead.

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

    A unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon Web Services advertises IP addresses. Use this parameter to limit the IP address to this location. IP addresses cannot move between network border groups.

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

    The ID of a customer-owned address pool. Use this parameter to let Amazon EC2 select an address from the address pool. Alternatively, specify a specific address from the address pool.

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

    The tags to assign to the Elastic IP address.

  • ipam_pool_id (Optional[IpamPoolId], default: None ) –

    The ID of an IPAM pool which has an Amazon-provided or BYOIP public IPv4 CIDR provisioned to it. For more information, see Allocate sequential Elastic IP addresses from an IPAM pool in the Amazon VPC IPAM User Guide.

  • 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 allocate an Elastic IP address This example allocates an Elastic IP address.

>>> client.allocate_address()
Source code in docs_src/capo_ec2/_services/ec2.py
def allocate_address(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    domain: Optional["capo_ec2.types.domain_type.DomainType"] = None,
    address: Optional["capo_ec2.types.public_ip_address.PublicIpAddress"] = None,
    public_ipv4_pool: Optional[
        "capo_ec2.types.ipv4_pool_ec2_id.Ipv4PoolEc2Id"
    ] = None,
    network_border_group: Optional["capo_ec2.types.string.String"] = None,
    customer_owned_ipv4_pool: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    ipam_pool_id: Optional["capo_ec2.types.ipam_pool_id.IpamPoolId"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.allocate_address_result.AllocateAddressResult":
    """<p>Allocates an Elastic IP address to your Amazon Web Services account. After you allocate the Elastic IP address you can associate it with an instance or network interface. After you release an Elastic IP address, it is released to the IP address pool and can be allocated to a different Amazon Web Services account.</p> <p>You can allocate an Elastic IP address from one of the following address pools:</p> <ul> <li> <p>Amazon's pool of IPv4 addresses</p> </li> <li> <p>Public IPv4 address range that you own and bring to your Amazon Web Services account using <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html">Bring Your Own IP Addresses (BYOIP)</a> </p> </li> <li> <p>An IPv4 IPAM pool with an Amazon-provided or BYOIP public IPv4 address range</p> </li> <li> <p>IPv4 addresses from your on-premises network made available for use with an Outpost using a <a href="https://docs.aws.amazon.com/outposts/latest/userguide/routing.html#ip-addressing">customer-owned IP address pool</a> (CoIP pool)</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html">Elastic IP Addresses</a> in the <i>Amazon EC2 User Guide</i>.</p> <p>If you release an Elastic IP address, you might be able to recover it. You cannot recover an Elastic IP address that you released after it is allocated to another Amazon Web Services account. To attempt to recover an Elastic IP address that you released, specify it in this operation.</p> <p>You can allocate a carrier IP address which is a public IP address from a telecommunication carrier, to a network interface which resides in a subnet in a Wavelength Zone (for example an EC2 instance).</p>

    Args:
        domain: <p>The network (<code>vpc</code>).</p>
        address: <p>The Elastic IP address to recover or an IPv4 address from an address pool.</p>
        public_ipv4_pool: <p>The ID of an address pool that you own. Use this parameter to let Amazon EC2 select an address from the address pool. To specify a specific address from the address pool, use the <code>Address</code> parameter instead.</p>
        network_border_group: <p> A unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon Web Services advertises IP addresses. Use this parameter to limit the IP address to this location. IP addresses cannot move between network border groups.</p>
        customer_owned_ipv4_pool: <p>The ID of a customer-owned address pool. Use this parameter to let Amazon EC2 select an address from the address pool. Alternatively, specify a specific address from the address pool.</p>
        tag_specifications: <p>The tags to assign to the Elastic IP address.</p>
        ipam_pool_id: <p>The ID of an IPAM pool which has an Amazon-provided or BYOIP public IPv4 CIDR provisioned to it. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/ipam/tutorials-eip-pool.html">Allocate sequential Elastic IP addresses from an IPAM pool</a> in the <i>Amazon VPC IPAM User Guide</i>.</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 allocate an Elastic IP address
        This example allocates an Elastic IP address.

        >>> client.allocate_address()
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.allocate_address_request.AllocateAddressRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.allocate_address_result.AllocateAddressResult"
    ]:
        import capo_ec2._operations.amazon_ec2.allocate_address

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AllocateAddress")
    )
    input_: capo_ec2.types.allocate_address_request.AllocateAddressRequest = {}
    if domain is not None:
        input_["domain"] = domain
    if address is not None:
        input_["address"] = address
    if public_ipv4_pool is not None:
        input_["public_ipv4_pool"] = public_ipv4_pool
    if network_border_group is not None:
        input_["network_border_group"] = network_border_group
    if customer_owned_ipv4_pool is not None:
        input_["customer_owned_ipv4_pool"] = customer_owned_ipv4_pool
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if ipam_pool_id is not None:
        input_["ipam_pool_id"] = ipam_pool_id
    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