问题
How can I migrate an EC2 instance to a different subnet with the same static IP Address (NOT ELASTIC ADDRESS)?
回答1:
-> Elastic IP address means Static or fixed IP address, other than that what ever public IP you receive during a session is temporary.
-> AWS will reassign you new public IP address when you start or stop your instance in a span of 5 to 10 minutes. ( irrespective of which subnet you are).
->Hence if you want to migrate EC2 instance with the same IP address, you need to assign an ELastic IP address.You can refer to this moving ec2 instances to another subnet
回答2:
To "migrate" an Amazon EC2 instance, you actually need to create a new Amazon EC2 instance. However, you can copy across the disk contents, so it appears to be the same instance.
To retain a public IP address, you should be using an Elastic IP address. This is a static IP address that is allocated to your AWS Account. You can then assign the IP address to any instance in the same region.
If you are not using an Elastic IP address, then it is not possible to keep the IP address. (It is not static.)
Steps:
- Use Create image to create an AMI of the existing instance. This takes a copy of the disks attached to the instance.
- Launch a new EC2 instance, specifying this new AMI and changing whatever settings you wish (eg subnet)
- Reassociate the Elastic IP address to the new instance
- Delete the old instance once you are happy that everything is working.
来源:https://stackoverflow.com/questions/63675596/migration-of-ec2-instance-to-a-different-subnet