Amazon Elastic Compute Cloud
API Reference (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

AssociateAddress

Description

This action applies to both EC2 Elastic IP addresses and VPC Elastic IP addresses.

For EC2 addresses: This action associates an Elastic IP address with an instance (not running in a VPC). If the IP address is currently assigned to another instance, the IP address is assigned to the new instance. For more information about EC2 Elastic IP addresses, go to Instance Addressing in the Amazon Elastic Compute Cloud User Guide.

For VPC addresses: This action associates a VPC Elastic IP address with an instance in your VPC. If the IP address is currently assigned to another instance, Amazon EC2 returns an error. For information about VPC addresses and how they differ from EC2 addresses, go to the Elastic IP Addresses in the Amazon Virtual Private Cloud User Guide.

This is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an error.

Request Parameters

NameDescriptionRequired

PublicIp

EC2 Elastic IP address to assign to the instance.

Type: String

Default: None

Condition: Required for EC2 Elastic IP addresses

Conditional

InstanceId

The instance to associate with the IP address.

Type: String

Default: None

Conditional

AllocationId

The allocation ID that AWS returned when you allocated the Elastic IP address for use with Amazon VPC.

Type: String

Default: None

Condition: Required for VPC Elastic IP addresses.

Conditional

NetworkInterfaceId

The network interface ID to associate with an instance. Association will fail when specifying an instance id unless exactly one interface is attached.

Type: String

Default: None

Condition: Available for VPC Elastic IP addresses only.

No

Response Elements

The elements in the following table are wrapped in an AssociateAddressResponse structure.

NameDescription

requestId

The ID of the request.

Type: xsd:string

return

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

Type: xsd:boolean

associationId

ID that AWS provides to represent the association of the address with an instance. Returned only for VPC Elastic IP addresses.

Type: xsd:string

Examples

Example Request

This example associates an EC2 Elastic IP address with an instance.

https://ec2.amazonaws.com/?Action=AssociateAddress
&InstanceId=i-2ea64347
&PublicIp=192.0.2.1
&AUTHPARAMS

Example Response

<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
  <return>true</return>
</AssociateAddressResponse>

Example Request

This example associates a VPC Elastic IP address with an instance in your VPC.

https://ec2.amazonaws.com/?Action=AssociateAddress
&InstanceId=i-4fd2431a
&AllocationId=eipalloc-5723d13e
&AUTHPARAMS

Example Response

<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
   <return>true</return>
   <associationId>eipassoc-fc5ca095</associationId>
</AssociateAddressResponse>