AllocateAddress
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 an address pool owned by Amazon or from an address pool created from a public IPv4 address range that you have brought to Amazon for use with your Amazon resources using bring your own IP addresses (BYOIP). For more information, see Bring Your Own IP Addresses (BYOIP) in the Amazon Elastic Compute Cloud User Guide.
[EC2-VPC] 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. You cannot recover an Elastic IP address for EC2-Classic. To attempt to recover an Elastic IP address that you released, specify it in this operation.
An Elastic IP address is for use either in the EC2-Classic platform or in a VPC. By default, you can allocate 5 Elastic IP addresses for EC2-Classic per Region and 5 Elastic IP addresses for EC2-VPC per Region.
For more information, see Elastic IP Addresses in the Amazon Elastic Compute Cloud User Guide.
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).
We are retiring EC2-Classic. We recommend that you migrate from EC2-Classic to a VPC. For more information, see Migrate from EC2-Classic to a VPC in the Amazon Elastic Compute Cloud User Guide.
Request Parameters
The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.
- Address
-
[EC2-VPC] The Elastic IP address to recover or an IPv4 address from an address pool.
Type: String
Required: No
- CustomerOwnedIpv4Pool
-
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.
Type: String
Required: No
- Domain
-
Indicates whether the Elastic IP address is for use with instances in a VPC or instances in EC2-Classic.
Default: If the Region supports EC2-Classic, the default is
standard
. Otherwise, the default isvpc
.Type: String
Valid Values:
vpc | standard
Required: No
- DryRun
-
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 isUnauthorizedOperation
.Type: Boolean
Required: No
- NetworkBorderGroup
-
A unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon advertises IP addresses. Use this parameter to limit the IP address to this location. IP addresses cannot move between network border groups.
Use DescribeAvailabilityZones to view the network border groups.
You cannot use a network border group with EC2 Classic. If you attempt this operation on EC2 Classic, you receive an
InvalidParameterCombination
error.Type: String
Required: No
- PublicIpv4Pool
-
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.Type: String
Required: No
- TagSpecification.N
-
The tags to assign to the Elastic IP address.
Type: Array of TagSpecification objects
Required: No
Response Elements
The following elements are returned by the service.
- allocationId
-
[EC2-VPC] The ID that Amazon assigns to represent the allocation of the Elastic IP address for use with instances in a VPC.
Type: String
- carrierIp
-
The carrier IP address. This option is only available for network interfaces which reside in a subnet in a Wavelength Zone (for example an EC2 instance).
Type: String
- customerOwnedIp
-
The customer-owned IP address.
Type: String
- customerOwnedIpv4Pool
-
The ID of the customer-owned address pool.
Type: String
- domain
-
Indicates whether the Elastic IP address is for use with instances in a VPC (
vpc
) or instances in EC2-Classic (standard
).Type: String
Valid Values:
vpc | standard
- networkBorderGroup
-
The set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon advertises IP addresses.
Type: String
- publicIp
-
The Elastic IP address.
Type: String
- publicIpv4Pool
-
The ID of an address pool.
Type: String
- requestId
-
The ID of the request.
Type: String
Errors
For information about the errors that are common to all actions, see Common client error codes.
Examples
Example for EC2-Classic
This example request allocates an Elastic IP address for use with instances in EC2-Classic.
Sample Request
https://ec2.amazonaws.com/?Action=AllocateAddress
&AUTHPARAMS
Sample Response
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<publicIp>192.0.2.1</publicIp>
<domain>standard</domain>
</AllocateAddressResponse>
Example for EC2-VPC
This example request allocates an Elastic IP address for use with instances in a VPC.
Sample Request
https://ec2.amazonaws.com/?Action=AllocateAddress
&Domain=vpc
&AUTHPARAMS
Sample Response
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<publicIp>198.51.100.1</publicIp>
<domain>vpc</domain>
<allocationId>eipalloc-5723d13e</allocationId>
</AllocateAddressResponse>
Example for Recovery
This example request shows how to recover an Elastic IP address that you previously released.
Sample Request
https://ec2.amazonaws.com/?Action=AllocateAddress
&Domain=vpc
&Address=203.0.113.3
&AUTHPARAMS
See Also
For more information about using this API in one of the language-specific Amazon SDKs, see the following: