Use CancelImportTask with a 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 CancelImportTask with a CLI

The following code examples show how to use CancelImportTask.

CLI
Amazon CLI

To cancel an import task

The following cancel-import-task example cancels the specified import image task.

aws ec2 cancel-import-task \ --import-task-id import-ami-1234567890abcdef0

Output:

{ "ImportTaskId": "import-ami-1234567890abcdef0", "PreviousState": "active", "State": "deleting" }
PowerShell
Tools for PowerShell

Example 1: This example cancels the specified import task (either snapshot or image import). If required, a reason can be providing using the -CancelReason parameter.

Stop-EC2ImportTask -ImportTaskId import-ami-abcdefgh
  • For API details, see CancelImportTask in Amazon Tools for PowerShell Cmdlet Reference.

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.