How to copy an EC2 instance to a new region?

,

I followed a few instructions online where I make a copy of the instance and then copy it over to a new region. Everything seemed straight forward except I can’t ssh to the machine nor can I http to it.

I’m not sure what I did wrong, I added firewall rules via aws to allow for ssh, http and https traffic inbound.

the ssh connection just times out.


Related discussions:

What instructions did you follow?

I’m curious what instructions you followed. Hopefully, they were something along the lines of either creating an AMI of your instance and copying to the other region. Or creating an EBS snapshot, copying that to the other region and creating another image with that then mounting that volume to the new instance.

If so, my guess would be the security groups are not the same as in the original region. Those would not have been copied automatically - you would need to recreate those in the new region.

https://www.cloudberrylab.com/resources/blog/how-to-move-amazon-ec2-to-different-availability-zone-vpc-region/

https://www.cloudberrylab.com/resources/blog/how-to-move-amazon-ec2-to-different-availability-zone-vpc-region/

This, or nacls

I created a new security group.

Can you show us the inbound and outbound rules in the new security group, compared to the old ones?

inbound i originally had ssh, http and https set but then i just added the default group which allows all traffic. I still can’t connect to the machine.
I had iptables running which only allowed ports 80/443 and 22, but I don’t see how that would break it.

First launch any instance on the target subnet/Az/region
Are you able to connect via rdp/ssh to the instance?

If u r not able to reach, then it has to be combination of SG, routing rule or incorrect subnet.

You can also try launching on default public subnet with ssh SG attached to it

yeah, i was able to launch a clean instance and connect.

what is SG?

SG is Security Group

The SSH connection timing out means that it’s gotta be Security Group or NACL blocking it.

If it was Connection Refused, then I would say SSH might not be running.

Are you using the default VPC in the other region? Could be that it’s not getting assigned a public address, no IGW, subnets not associated with a route table, route table with no IGW, etc… default VPC in region is setup to account for that. Are there other instances in the AZ/subnet you can connect into for the new regional assignment? If so, see if you can connect via backend IP to instance as well.

Out of curiosity, are you using the old IP / DNS record? It may seem obvious, but the new machine will have its own IP and any DNS entry you had will no longer work.

i’m not even using the domain name yet. i’m just directly sshing to the public dns name amazon assigns. But maybe the server is configured for the old IP still.

I’m not sure. I have to look into what a VPC is.

It could also be that the instance is in a private subnet (no IGW) or has no publicly-routable IP (elastic/public IP), right?

Probably a few other things I’m forgetting too…

edit: Nice troubleshooting list here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectionTimeout

https://www.youtube.com/watch?v=ZLNgAncOOK4

i followed these steps. twice now. if i create a new instance it works fine, if i copy an instance from another region i cannot connect to the machine and the status check fails for one of the tests that check if the server is available.

If I take a screenshot of the machine I see a login screen and I don’t see any errors in the bootup log.

https://www.youtube.com/watch?v=ZLNgAncOOK4