How to export a VM from Amazon EC2 to VMware On-Premise

Here are the instructions on how to communicate with Amazon’s API to export a VM from Amazon EC2 to a VMware image that gets put into S3 storage.  From that point, you can simply download the VMware image and import it into your VMware environment.

0. Open up a command prompt

1. Setup your java path (you can use JRE or JDK):
set JAVA_HOME=”C:\Program Files\Java\jre6″

2. Verify your version with this command (you should see the java version number):
%JAVA_HOME%\bin\java -version

3. Add the bin directory that contains the java executable to your path before other versions of java
set PATH=%java_home%\bin;”%Path%”

4. Verify you can see the java version by executing the following command:
java -version

5. Set the EC2_HOME path
SET EC2_HOME=c:\ec2-api-tools-1.6.5.4

6. Verify the ec2_home using
dir %EC2_HOME%

7. Update the path
set PATH=”%PATH%”;%EC2_HOME%\bin

8. Setup access key environment variables
set AWS_ACCESS_KEY=XXXXXXXXXXXXXXXXXX
set AWS_SECRET_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

9. Verify the tools setup — if setup correctly, we should be able to view our available regions.
ec2-describe-regions

10. Execute the following command:
ec2-create-instance-export-task i-EC2INSTANCENAME -e VMware -f VMDK -c ova -b S3STORAGEBUCKET

Once you have executed the command above, you can use the following commands to track/manage the cloning process.

  • Use ec2-describe-export-tasks to monitor the export progress
  • Use ec2-cancel-export-task to cancel an export task prior to completion

 

Notes: You could easily take steps 1-8 to setup an automated script to connect to amazon’s services.  If you would like more information on these steps, here was a great article I ran across explaining everything in detail.

http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html

 

2 thoughts on “How to export a VM from Amazon EC2 to VMware On-Premise

  1. David Watt

    Have you put together a similar set of instructions for an AMI that you did not initially import into Amazon? These instructions fail if the AMI was created on Amazon, with a message saying that it was not imported.

    Reply
    1. Jack Post author

      I do not. I contacted Amazon awhile back when trying to export images out of their environment and they said their APIs have a ton of limitations on what exactly can be exported from their environment and converted back into the VMware format.

      The biggest issue we had was almost all of our deployments had multiple disks attached to the host (limitation when creating the VMware format). We ended up having to recreate all of the instances manually in our on-premise environment.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.