Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

AssignPrivateIpAddresses

Assigns one or more secondary private IP addresses to the specified network interface. You can specify one or more specific secondary IP addresses, or you can specify the number of secondary IP addresses to be automatically assigned within the subnet's CIDR block range. The number of secondary IP addresses that you can assign to an instance varies by instance type. For information about instance types, see Instance Types in the Amazon Elastic Compute Cloud User Guide. For more information about Elastic IP addresses, see Elastic IP Addresses in the Amazon Elastic Compute Cloud User Guide.

AssignPrivateIpAddresses is available only in EC2-VPC.

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.

AllowReassignment

Indicates whether to allow an IP address that is already assigned to another network interface or instance to be reassigned to the specified network interface.

Type: Boolean

Required: No

NetworkInterfaceId

The ID of the network interface.

Type: String

Required: Yes

PrivateIpAddress.N

One or more IP addresses to be assigned as a secondary private IP address to the network interface. You can't specify this parameter when also specifying a number of secondary IP addresses.

If you don't specify an IP address, Amazon EC2 automatically selects an IP address within the subnet range.

Type: Array of strings

Required: No

SecondaryPrivateIpAddressCount

The number of secondary IP addresses to assign to the network interface. You can't specify this parameter when also specifying private IP addresses.

Type: Integer

Required: No

Response Elements

The following elements are returned by the service.

requestId

The ID of the request.

Type: String

return

Is true if the request succeeds, and an error otherwise.

Type: Boolean

Errors

For information about the errors that are common to all actions, see Common Errors.

Examples

Example 1

This example assigns two secondary private IP addresses (10.0.2.1 and 10.0.2.11) to the specified network interface.

Sample Request

Copy
https://ec2.amazonaws.com/?Action=AssignPrivateIpAddresses &NetworkInterfaceId=eni-d83388b1 &PrivateIpAddress.1=10.0.2.1 &PrivateIpAddress.2=10.0.2.11 &AUTHPARAMS

Sample Response

Copy
<AssignPrivateIpAddresses xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </AssignPrivateIpAddresses>

Example 2

This example assigns two secondary private IP addresses to the specified network interface. Amazon EC2 automatically assigns these IP addresses from the available IP addresses within the subnet's CIDR block range.

Sample Request

Copy
https://ec2.amazonaws.com/?Action=AssignPrivateIpAddresses &NetworkInterfaceId=eni-d83388b1 &SecondaryPrivateIpAddressCount=2 &AUTHPARAMS

Sample Response

Copy
<AssignPrivateIpAddresses xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </AssignPrivateIpAddresses>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: