Skip to content

How do I use VM Import/Export to export an AMI of my Amazon EC2 instance as a VM?

2 minute read
0

I want to export the Amazon Machine Image (AMI) of my Amazon Elastic Compute Cloud (Amazon EC2) instance as a virtual machine (VM).

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Prerequisites:

  • Check the image export requirements to verify that you can use VM Import/Export to export your EC2 instance's AMI.
  • If you sign in as an AWS Identity and Access Management (IAM) user, then confirm that you have the required permissions to use VM Import/Export.
  • (Windows only) You must originally import the instance as a Bring your own license (BYOL) through VM Import/Export, AWS Application Migration Service, or AWS Elastic Disaster Recovery. You can't export a Windows instance that you created from a Windows AMI provided by AWS or a Windows Marketplace AMI.

To export an AMI of your instance, complete the following steps:

  1. Create an Amazon Elastic Block Store (Amazon EBS)-backed AMI of the instance that you want to export.
  2. Create an Amazon Simple Storage Service (Amazon S3) bucket in the same AWS Region as the AMI that you want to export.
  3. Activate AWS Security Token Service (AWS STS) in the Region that you want to use for VM Import/Export.
  4. Create the required VM Import/Export service role.
  5. Export your image.
    Note: When you export the image, note the value for ExportImageTaskId.
  6. To check the status of your export image task, run the following describe-export-image-tasks AWS CLI command:
    aws ec2 describe-export-image-tasks --export-image-task-ids export-example-ami-id
    Note: Replace export-example-ami-id with your export task ID.
    Example output:
    {    "ExportImageTasks": [        {
                "ExportImageTaskId": "export-ami-1234567890abcdef0",
                "Progress": "21",
                "S3ExportLocation": {
                    "S3Bucket": "my-export-bucket",
                    "S3Prefix": "exports/"
                },
                "Status": "active",
                "StatusMessage": "updating"
            }
        ]
    }
    If the Status is completed, then your exported file is ready as an object in your Amazon S3 bucket.
  7. Download the object from your S3 bucket.

Related information

Export a VM from an Amazon Machine Image (AMI) using VM Import/Export

Amazon Machine Images in Amazon EC2

Troubleshooting VM Import/Export

AWS OFFICIALUpdated 3 months ago
2 Comments

The step 6 is not aws ec2 describe-export-image-tasks --example-image-task-id example-ami-id. Instead it is aws ec2 describe-export-image-tasks --export-image-task-id export-example-ami-id

replied 2 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

AWS
MODERATOR
replied 2 years ago