- Newest
- Most votes
- Most comments
Hello.
If the subnets are different, the IP address will change, as you recognize.
If the IP address absolutely cannot be changed, it can be handled by removing routes destined for the Internet Gateway from the route table of the currently activated subnet and changing it to a private subnet.
However, this method is not recommended if EC2 other than the DB instance is running on the same subnet, as the impact may be significant.
If you are moving subnets, you can create a snapshot of EC2, create an AMI from the snapshot, and then create EC2 from the AMI.
In the case of this method, moving is easy, but it would be necessary to stop applications and other services because data updated during the move will not be saved.
Another method is to use a DMS.
This method should result in less data loss than restoring and moving from AMI.
Note, however, that you will need to configure the DMS and that there is a cost for something called a replication instance.
https://docs.aws.amazon.com/dms/latest/userguide/Welcome.html
If you can provide some downtime to move subnets, I would recommend restoring from AMI.
To avoid such issues, try to not to use IPs when comes to databases/EC2s. Not sure how many code changes are required, at this stage, but you can consider creating a R53 private hosted zone. Update your code to use the R53 record. When you export/import your DB to the new instance just update the R53 to point to the new IP.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Thanks for the reply, we can not move routes as well as you correctly mentioned there are other EC2 instances in that subnet. Looks like best way is, we have to compromise on the sticking on the same IP Address and get a new one. Thanks.