There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateInstanceExportTask with a CLI
The following code examples show how to use CreateInstanceExportTask.
- CLI
-
- AWS 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-idi-1234567890abcdef0--target-environmentvmware--export-to-s3-taskDiskImageFormat=vmdk,ContainerFormat=ova,S3Bucket=myexportbucket,S3Prefix=RHEL5Output:
{ "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" } }-
For API details, see CreateInstanceExportTask
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example exports a stopped instance,
i-0800b00a00EXAMPLE, as a virtual hard disk (VHD) to the S3 buckettestbucket-export-instances-2019. The target environment isMicrosoft, and the region parameter is added because the instance is in theus-east-1region, while the user's default AWS Region is not us-east-1. To get the status of the export task, copy theExportTaskIdvalue from the results of this command, then runGet-EC2ExportTask -ExportTaskId export_task_ID_from_results.New-EC2InstanceExportTask -InstanceId i-0800b00a00EXAMPLE -ExportToS3Task_DiskImageFormat VHD -ExportToS3Task_S3Bucket "amzn-s3-demo-bucket" -TargetEnvironment Microsoft -Region us-east-1Output:
Description : ExportTaskId : export-i-077c73108aEXAMPLE ExportToS3Task : Amazon.EC2.Model.ExportToS3Task InstanceExportDetails : Amazon.EC2.Model.InstanceExportDetails State : active StatusMessage :-
For API details, see CreateInstanceExportTask in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example exports a stopped instance,
i-0800b00a00EXAMPLE, as a virtual hard disk (VHD) to the S3 buckettestbucket-export-instances-2019. The target environment isMicrosoft, and the region parameter is added because the instance is in theus-east-1region, while the user's default AWS Region is not us-east-1. To get the status of the export task, copy theExportTaskIdvalue from the results of this command, then runGet-EC2ExportTask -ExportTaskId export_task_ID_from_results.New-EC2InstanceExportTask -InstanceId i-0800b00a00EXAMPLE -ExportToS3Task_DiskImageFormat VHD -ExportToS3Task_S3Bucket "amzn-s3-demo-bucket" -TargetEnvironment Microsoft -Region us-east-1Output:
Description : ExportTaskId : export-i-077c73108aEXAMPLE ExportToS3Task : Amazon.EC2.Model.ExportToS3Task InstanceExportDetails : Amazon.EC2.Model.InstanceExportDetails State : active StatusMessage :-
For API details, see CreateInstanceExportTask in AWS Tools for PowerShell Cmdlet Reference (V5).
-