{"id":1148,"date":"2014-04-22T00:25:32","date_gmt":"2014-04-22T00:25:32","guid":{"rendered":"http:\/\/www.omniweb.com\/wordpress\/?p=1148"},"modified":"2014-04-22T00:27:33","modified_gmt":"2014-04-22T00:27:33","slug":"copy-an-amazon-ec2-instance-to-a-new-region","status":"publish","type":"post","link":"https:\/\/www.omniweb.com\/wordpress\/?p=1148","title":{"rendered":"Copy an Amazon EC2 instance to a new region"},"content":{"rendered":"<p>I thought this would be easier than it turned out to be.  Documenting my steps here in case I need to do this again someday.<\/p>\n<p>I had a running Amazon EC2 instance and I want to copy it for possible migration to a different Amazon region.<\/p>\n<p>I created the snapshot of the boot drive, and copied that over to the desired destination region.  Then I created an image from the snapshot and tried to launch that image with the default kernel option.  The system starts running but fails 1\/2 checks and is not reachable.  I looked around and found some similar cases:<br \/>\n<a href=\"https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=452648\">https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=452648<\/a><br \/>\n<a href=\"https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=292162\">https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=292162<\/a><br \/>\n<a href=\"https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=388700\">https:\/\/forums.aws.amazon.com\/thread.jspa?messageID=388700<\/a><\/p>\n<p>These posts clued me in to the kernel.  I found which Amazon kernel image the source is running, but that kernel can&#8217;t be found in the destination region.  At first I thought maybe it&#8217;s obsolete, or region-specific, but then I figured out how to find the correct kernel in the new region.<\/p>\n<p>Look at the source instance in the source region, and find the AMI ID in the instance description.  In my case it is<br \/>\nubuntu-lucid-10.04-i386-server-20101020 (ami-8c0c5cc9)<\/p>\n<p>Switch to the destination region and view the AMIs, switch to public AMIs and search based on the description (ubuntu-lucid-10.04-i386-server-20101020)<br \/>\nThis brings up 2 results, I&#8217;m looking for the &#8216;ebs&#8217; result.<\/p>\n<p>Click on it and in the Details look for the Kernel ID, in my case it is aki-6603f70f<\/p>\n<p>Now I can launch my snapshot-sourced AMI and choose this kernel ID under Advanced.  My server comes up and passes 2\/2 checks now, but I still can&#8217;t connect.  I&#8217;m getting &#8220;Connection refused&#8221; even though the same security group allows me to connect to a neighboring instance.<\/p>\n<p>This explained it for me: <a href=\"http:\/\/stackoverflow.com\/questions\/14026148\/running-ec2-instance-suddenly-refuses-ssh-connection\">http:\/\/stackoverflow.com\/questions\/14026148\/running-ec2-instance-suddenly-refuses-ssh-connection<\/a><\/p>\n<p>I had to temporarily attach the volume to a different running instance in the same region &#038; zone so that I could modify \/etc\/fstab to remove the defunct entries. After doing this, I re-attached the volume to the new instance as \/dev\/sda1 and then it booted with 2\/2 checks passing and I am able to connect using SSH.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I thought this would be easier than it turned out to be. Documenting my steps here in case I need to do this again someday. I had a running Amazon EC2 instance and I want to copy it for possible &hellip; <a href=\"https:\/\/www.omniweb.com\/wordpress\/?p=1148\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1148"}],"collection":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1148"}],"version-history":[{"count":3,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1148\/revisions"}],"predecessor-version":[{"id":1151,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1148\/revisions\/1151"}],"wp:attachment":[{"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.omniweb.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}