Amazon created a copy tool that is much simpler to use than this guide.
I made another guide that goes over the new tool at
http://www.whiteboardcoder.com/2013/04/copy-ami-between-regions.html
Should the new tool not work for you this older guide may be helpful
I recently had a need to move an AMI from the AWS east-1 regions to the west-2 region.
I made another guide that goes over the new tool at
http://www.whiteboardcoder.com/2013/04/copy-ami-between-regions.html
Should the new tool not work for you this older guide may be helpful
I recently had a need to move an AMI from the AWS east-1 regions to the west-2 region.
AWS does have a command line tool, ec2-migrate-image, for
moving AMIs between regions, but it does not work for EBS backed AMIs (which I
prefer to use) For more information on this command line tool
go to http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-MigrateImage.html
[1]
I use Ubuntu EBS images.
These AMIs are listed at http://uec-images.ubuntu.com/releases/
[2] In particular I use 12.04 which can
be located at http://uec-images.ubuntu.com/releases/precise/release/
If you look for
us-east-1 64 bits EBS you find the AMI
ami-fd20ad94
us-west-2 64 bits EBS
you find the AMI
ami-7e2da54e
I bring this up because If I am going to copy an Ubuntu EBS
machine from one region to another its important to know which linux kernel
needs to be applied in that region.
To show how this all works I am first going to launch an
ubuntu 12.04 EBS instance in the East coast.
Launch Instance
From the EC2 console select AMIs then select, from the pull
down, all images, All platforms and enter ami-fd20ad94. Then click Enter.
Select the Ubuntu AMI and click Launch
Select 1 instance and make it a T1.micro and click Continue
Leave the defaults and just click Continue
Leave the defaults and just click Continue
Leave the defaults and just click Continue
Choose your key pair and click continue
Select the default security group and click continue
Click Launch
SSH into this instance
(make sure your security group allows port 22)
> ssh –i .ec2/pats-keypair.pem ubuntu@ec2-54-234-55-203.compute-1.amazonaws.com
|
I like to create a file just to make sure I really made a
copy. So use touch to make a file
> touch test_file.txt
|
Convert the machine to an AMI
In order to move this machine to the West Region we first
need to turn it into an AMI in the east region
From the EC2 console click on instances and select the
instance that was just made.
Click on Actions and select “Create Image (EBS AMI)”
Leave the defaults and click Yes, Create
Click on AMIs select Owned by me and you should see the AMI
you just made.
In my case ami-c30b84aa
Select Snapshots and search for the AMI you just created (in
my case ami-c30b84a)
Select the snapshot
Click on Copy
Select Us West Oregon,
Enter a Description and click yes, Copy
Copy has been initiated
Switch over the US West Oregon Region
Now before you get too far you need to determine which linux
kernel you need to use. Since I am using
Ubuntu I want my kernel to be the same as the kernel ubuntu uses in this region
for the same type of server (64-bit EBS)
To find out which kernel to use look up the regions AMI.
In this case the
ami-7e2da54e
Click on AMIs and search for ami-7e2da54e
And select it.
The kernel id for this ami is aki-98e26fa8
Now to create an ami from the copied snapshot
Select Snapshots,
Enter in “Test” to narrow the search.
Select the snapshot that was moved from the east coast and click on
Create Image
Give it a name and select x86_64 then select the kernel ID aki-98e26fa8
Click Yes, Create
Click on AMIs select the AMI that was just made and click
Launch.
Use the same simple procedure to launch this instance in the
west coast as was done in the east coast.
Or for your command line junkies, like me, you can simply
run this command.
(remember your keys on the east region do not apply to the
west, each region has its own set of keys… so you may need to make some new
keys)
> ec2-run-instances ami-dee76cee -b /dev/sda1=:8:true -k west-pats-keypair
-t t1.micro --availability-zone us-west-2a --region us-west-2
|
Click on Instances and select the newly made instance and
find its DNS
Log into it
> ssh -i .ec2/west-pats-keypair.pem ubuntu@ec2-50-112-209-137.us-west-2.compute.amazonaws.com
|
After logging in I do a quick ls –alh
And you can see the test file that was made.
So that is the way to copy an EBS AMI over to another region. I wish there was a simpler way.
References
[1] ec2-migrate-image command
line tool
Visited 12/2012
[2] Ubuntu Cloud Images
Visited 12/2012
No comments:
Post a Comment