| Did this page help you? Yes No Tell us about it... |
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.
| Name | Description | Required |
|---|---|---|
|
|
EC2 Elastic IP address to assign to the instance. Type: String Default: None Condition: Required for EC2 Elastic IP addresses |
Conditional |
|
|
The instance to associate with the IP address. Type: String Default: None |
Conditional |
|
|
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 |
|
|
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 |
The elements in the following table are wrapped in an
AssociateAddressResponse structure.
| Name | Description |
|---|---|
|
|
The ID of the request. Type: xsd:string |
|
|
Returns true if the request succeeds. Otherwise, returns an error. Type: xsd:boolean |
|
|
ID that AWS provides to represent the association of the address with an instance. Returned only for VPC Elastic IP addresses. Type: xsd:string |
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
<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </AssociateAddressResponse>
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
<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>