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:
- Create an Amazon Elastic Block Store (Amazon EBS)-backed AMI of the instance that you want to export.
- Create an Amazon Simple Storage Service (Amazon S3) bucket in the same AWS Region as the AMI that you want to export.
- Activate AWS Security Token Service (AWS STS) in the Region that you want to use for VM Import/Export.
- Create the required VM Import/Export service role.
- Export your image.
Note: When you export the image, note the value for ExportImageTaskId.
- 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.
- 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