How do I move an Elastic IP address to a different EC2 instance?

2 minute read
0

I want to move my Elastic IP address to a different Amazon Elastic Compute Cloud (Amazon EC2) instance.

Resolution

Use the EC2 console

1.    Open the Amazon EC2 console, then select Elastic IPs.

2.    Choose the Elastic IP address that you want to transfer.

3.    Verify the Association ID and Associated instance ID to confirm which instance the Elastic IP address is currently associated with.

4.    Select Actions, Disassociate Elastic IP address.

5.    Select Disassociate.

6.    Select the Elastic IP address again, and then select Actions, Associate Elastic IP address.

7.    Select Instance and then search for the Instance ID of the instance that you want to associate the Elastic IP address with.

Note: If you have multiple network interfaces on the EC2 instance, then do the following:

Select Network Interface.

Choose the Elastic Network Interface ID that you want to associate the Elastic IP address with.

8.    Select Associate.

Use the AWS Command Line Interface (AWS CLI)

Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.

1.    Run the describe-addresses command to confirm which EC2 instance the Elastic IP address is currently associated with. In the following command, replace x.x.x.x with the Elastic IP address that you want to move to a different EC2 instance.

aws ec2 describe-addresses --public-ips x.x.x.x

2.    If the Elastic IP address is associated with an instance, then run the disassociate-address command. In the following example command, replace x.x.x.x with the Elastic IP address that you want to move to a different EC2 instance.

aws ec2 disassociate-address --public-ip x.x.x.x

3.    Run the describe-addresses command again to confirm the current association status. If the command doesn't return an Association ID, then the Elastic IP successfully disassociated.

4.    Run the associate-address command. In the following example command, replace instance-id with the ID of the instance that you want to associate the Elastic IP address with. And, replace x.x.x.x with the Elastic IP address that you're moving.

aws ec2 associate-address --instance-id i-abcde12345 --public-ip x.x.x.x

For more information, see associate-address.

Note: If the EC2 instance has multiple elastic network interfaces, then use the --allocation-id and --network-interface-id parameters.

5.    Run the describe-addresses command to confirm the Elastic IP address association.

AWS OFFICIAL
AWS OFFICIALUpdated 10 months ago