Amazon Elastic Compute Cloud
API Reference (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

AssignPrivateIpAddresses

Description

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 Available 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.

This action is available only in EC2-VPC.

Request Parameters

NetworkInterfaceId

The network interface to which the IP address is assigned.

Type: String

Default: None

Required: Yes

PrivateIpAddress.n

The IP address to be assigned as a secondary private IP address to the network interface.

This option can be used multiple times to assign multiple secondary private IP addresses to the network interface.

Type: AssignPrivateIpAddressesSetItemRequestType

Default: None

Required: Conditional

Condition: You cannot specify this parameter when also specifying SecondaryPrivateIpAddressCount.

SecondaryPrivateIpAddressCount

The number of secondary IP addresses to assign to the network interface.

Type: Integer

Default: None

Required: Conditional

Condition: You cannot specify this parameter when also specifying PrivateIPAddress.n.

AllowReassignment

Specifies 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

Default: False

Required: No

Response Elements

The following elements are returned in an AssignPrivateIpAddressesResponse element.

requestId

The ID of the request.

Type: xsd:string

return

Returns true if the request succeeds. Otherwise, returns an error.

Type: xsd:boolean

Examples

Example Request

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

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

Example Response

<AssignPrivateIpAddresses xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
   <return>true</return>
</AssignPrivateIpAddresses>

Example Request

This example assigns two secondary private IP addresses to the network interface. The IP addresses are automatically assigned from the available IP addresses within the subnet's CIDR block range.

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

Example Response

<AssignPrivateIpAddresses xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
   <return>true</return>
</AssignPrivateIpAddresses>