Use CreateInstanceExportTask with an Amazon SDK or CLI - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use CreateInstanceExportTask with an Amazon SDK or CLI

The following code examples show how to use CreateInstanceExportTask.

CLI
Amazon CLI

To export an instance

This example command creates a task to export the instance i-1234567890abcdef0 to the Amazon S3 bucket myexportbucket.

Command:

aws ec2 create-instance-export-task --description "RHEL5 instance" --instance-id i-1234567890abcdef0 --target-environment vmware --export-to-s3-task DiskImageFormat=vmdk,ContainerFormat=ova,S3Bucket=myexportbucket,S3Prefix=RHEL5

Output:

{ "ExportTask": { "State": "active", "InstanceExportDetails": { "InstanceId": "i-1234567890abcdef0", "TargetEnvironment": "vmware" }, "ExportToS3Task": { "S3Bucket": "myexportbucket", "S3Key": "RHEL5export-i-fh8sjjsq.ova", "DiskImageFormat": "vmdk", "ContainerFormat": "ova" }, "Description": "RHEL5 instance", "ExportTaskId": "export-i-fh8sjjsq" } }
PowerShell
Tools for PowerShell

Example 1: This example exports a stopped instance, i-0800b00a00EXAMPLE, as a virtual hard disk (VHD) to the S3 bucket testbucket-export-instances-2019. The target environment is Microsoft, and the region parameter is added because the instance is in the us-east-1 region, while the user's default Amazon Region is not us-east-1. To get the status of the export task, copy the ExportTaskId value from the results of this command, then run Get-EC2ExportTask -ExportTaskId export_task_ID_from_results.

New-EC2InstanceExportTask -InstanceId i-0800b00a00EXAMPLE -ExportToS3Task_DiskImageFormat VHD -ExportToS3Task_S3Bucket "testbucket-export-instances-2019" -TargetEnvironment Microsoft -Region us-east-1

Output:

Description : ExportTaskId : export-i-077c73108aEXAMPLE ExportToS3Task : Amazon.EC2.Model.ExportToS3Task InstanceExportDetails : Amazon.EC2.Model.InstanceExportDetails State : active StatusMessage :

For a complete list of Amazon SDK developer guides and code examples, see Create Amazon EC2 resources using an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.