I want to launch an Amazon Elastic Compute Cloud (Amazon EC2) instance from a backup. I want to use the same IP address as the original EC2 instance.
Short description
To recover an instance from backup, you typically launch a new instance from an Amazon Machine Image (AMI) or snapshot. By default, Amazon EC2 assigns a new IP address to the new instance.
To keep the public IP address, associate an Elastic IP address to the instance.
To keep the original private IP address, attach the original elastic network interface to the new instance. This method also keeps any existing network interface settings, such as secondary IP addresses. To not keep the network interface settings, you can instead specify the original IP address when you launch the new instance.
Resolution
Prerequisites: Create an AMI of your instance to back up the instance configuration, operating system (OS), and data. Also, create snapshots of your Amazon Elastic Block Store (Amazon EBS) volumes as an additional backup.
Associate an Elastic IP address to the instance
To keep the same public IP address, associate an Elastic IP address with your instance.
Attach the original network interface to the new instance
Complete the following steps:
- Modify the network interface configuration to clear Delete on termination.
- Terminate the original instance.
Note: Wait for the instance state to show as Terminated.
- Launch a new instance and configure the following settings:
For AMI, select the AMI that you created of your original instance.
Under Network settings, choose Edit.
For VPC, select the same virtual private cloud (VPC) as the original instance, and for Subnet, select the same subnet as the original instance.
Note: The private IP address must be within the CIDR block of the new instance's subnet.
Expand Advanced network configuration, and then for Network interface, select the network interface.
Specify the private IP address during launch
Important: The private IP address is attached to the instance's primary network interface. To use an existing IP address, you must terminate the original instance.
Complete the following steps:
- Open the Amazon EC2 console.
- In the navigation pane, choose Instances, and then select your instance.
- Note the value for Private IPv4 address.
- Terminate the instance.
Note: Wait for the instance state to show as Terminated.
- Launch a new instance and configure the following settings:
Under Network settings, choose Edit.
For VPC, select the same VPC as the original instance, and for Subnet, select the same subnet as the original instance.
Note: The private IP address must be within the CIDR block of the new instance's subnet.
Expand Advanced network configuration, and then for Primary IP, enter the private IP address.
- (Optional) Manually assign your instance's secondary private IP address.
Troubleshoot issues
If the recovered instance doesn't work as expected, then terminate the new instance. Then, launch an instance from the AMI that you took of the original instance. Under Advanced network configuration, for Primary IP, enter the private IP address.
Related information
How do I assign a custom primary private IP address to my Amazon EC2 instance?