Can we move ec2 instances from private subnet to public subnet directly?

5.6k views Asked by At

I want to move my ec2-instances from private subnet to public subnet. Is there is a way to do that other than creating AMI of those instances and then launching new instances from those AMI's and attaching volumes and elastic ips with them?

1

There are 1 answers

0
John Rotenstein On

An Amazon EC2 instance is permanently connected to a subnet. (Well, the Primary interface is.)

Some options:

  1. You could modify the subnet so that the subnet 'becomes' a public subnet (by configuring the Route Table to send traffic to an Internet Gateway). This does not require any changes to the instance itself.

  2. You could add a secondary Elastic Network Interface (ENI) that connects it to a public subnet. You then need to configure the operating system to use the secondary ENI.

  3. You could launch a new instance in a public subnet, stop it, detach its disks, then attach the disks from the 'private' instance, then start it. It will probably start up okay, and it would then be in a public subnet.