

# Import a disk as an EBS snapshot using VM Import/Export
<a name="vmimport-import-snapshot"></a>

VM Import/Export enables you to import your disks as Amazon EBS snapshots. After the snapshot is created, you can create an EBS volume from the snapshot, and then attach the volume to an EC2 instance.

An imported snapshot has an arbitrary volume ID that should not be used for any purpose.

## Prerequisites for importing a snapshot
<a name="import-snapshot-prerequisites"></a>
+ The following disk formats are supported: Virtual Hard Disk (VHD/VHDX), ESX Virtual Machine Disk (VMDK), and raw.
+ You must first upload your disks to Amazon S3.
+ If you have not already installed the AWS CLI on the computer you'll use to run the import commands, see the [AWS Command Line Interface User Guide](https://docs.aws.amazon.com/cli/latest/userguide/).
**Tip**  
In [supported AWS Regions](https://docs.aws.amazon.com/cloudshell/latest/userguide/supported-aws-regions.html), you can also use [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html) for a browser-based, pre-authenticated shell that launches directly from the AWS Management Console.

## Start an import snapshot task
<a name="start-import-task"></a>

You can specify the URL of the S3 bucket that contains the disk image or provide the S3 bucket name and key.

------
#### [ AWS CLI ]

**To import a snapshot**  
Use the [import-snapshot](https://docs.aws.amazon.com/cli/latest/reference/ec2/import-snapshot.html) command.

```
aws ec2 import-snapshot \
    --description "My server VM" \
    --disk-container "file://C:\import\containers.json"
```

The file `containers.json` is a JSON document that contains the required information.

```
{
    "Description": "My server VM",
    "Format": "VMDK",
    "UserBucket": {
        "S3Bucket": "amzn-s3-demo-import-bucket",
        "S3Key": "vms/my-server-vm.vmdk"
    }
}
```

The following is example output.

```
{
    "Description": "My server VM",
    "ImportTaskId": "import-snap-1234567890abcdef0",
    "SnapshotTaskDetail": {
        "Description": "My server VMDK",
        "DiskImageSize": "0.0",
        "Format": "VMDK",
        "Progress": "3",
        "Status": "active",
        "StatusMessage": "pending",
        "UserBucket": {
            "S3Bucket": "amzn-s3-demo-import-bucket",
            "S3Key": "vms/my-server-vm.vmdk"
        }
    }
}
```

------
#### [ PowerShell ]

**To import a snapshot**  
Use the [Import-EC2Snapshot](https://docs.aws.amazon.com/powershell/latest/reference/items/Import-EC2Snapshot.html) cmdlet.

```
Import-EC2Snapshot `
    -DiskContainer_Description "My server VM" `
    -DiskContainer_Format "VMDK" `
    -DiskContainer_S3Bucket "amzn-s3-demo-import-bucket" `
    -DiskContainer_S3Key "vms/my-server-vm.vmdk"
```

The following is example output.

```
Description  ImportTaskId                  SnapshotTaskDetail                  Tags
-----------  ------------                  ------------------                  ----
My server VM import-snap-1234567890abcdef0 Amazon.EC2.Model.SnapshotTaskDetail
```

------

# Monitor an import snapshot task
<a name="check-status-import-task"></a>

After you start an import snapshot task using VM Import/Export, you can monitor the import operation. If the task status is `active`, it means that the import task is in progress. The snapshot is ready to use when the status is `completed`.

------
#### [ AWS CLI ]

**To get the status of an import snapshot task**  
Use the following [describe-import-snapshot-tasks](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-import-snapshot-tasks.html) command.

```
aws ec2 describe-import-snapshot-tasks \
    --import-task-ids import-snap-1234567890abcdef0
```

The following is example output.

```
{
    "ImportSnapshotTasks": [
        {
            "Description": "My server VM",
            "ImportTaskId": "import-snap-1234567890abcdef0",
            "SnapshotTaskDetail": {
                "Description": "My server VMDK",
                "DiskImageSize": "3.115815424E9",
                "Format": "VMDK",
                "Progress": "22",
                "Status": "active",
                "StatusMessage": "downloading/converting",
                "UserBucket": {
                    "S3Bucket": "amzn-s3-demo-import-bucket",
                    "S3Key": "vms/my-server-vm.vmdk"
                },
            }
        }
    ]
}
```

**To get the status of all import snapshot tasks**  
Use the following [describe-import-snapshot-tasks](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-import-snapshot-tasks.html) command.

```
aws ec2 describe-import-snapshot-tasks \
    --query "ImportSnapshotTasks[*].{Description:Description, ImportTaskId:ImportTaskId, Status:SnapshotTaskDetail.Status, Progress: SnapshotTaskDetail.Progress, SnapshotID: SnapshotTaskDetail.SnapshotId,  S3Key: SnapshotTaskDetail.UserBucket.S3Key}" \
    --output table
```

The following is example output. You can display any additional fields that you need.

```
----------------------------------------------------------------------------------------------------------------------------
|                                                    DescribeImportSnapshotTasks                                           |
+--------------+--------------------------------+-------------+-----------+----------------------+-------------------------+
|  Description |         ImportTaskId           |   Status    | Progress  |        S3Key         |       SnapshotID        |
+--------------+--------------------------------+-------------+-----------+----------------------+-------------------------+
|  My server VM|  import-snap-1234567890abcdef0 |  active     |  19       |  my-server-vm.vmdk   |                         |
|  My server VM|  import-snap-1234567890abcdef1 |  completed  |  None     |  my-server-vm1.vmdk  |  snap-0bd3ea32600000000 |
|  My server VM|  import-snap-1234567890abcdef2 |  completed  |  None     |  my-server-vm2.vmdk  |  snap-090ec0d0eb1111111 |
|  My server VM|  import-snap-1234567890abcdef3 |  deleted    |  None     |  my-server-vm3.vmdk  |                         |
+--------------+--------------------------------+-------------+-----------+----------------------+-------------------------+
```

------
#### [ PowerShell ]

**To get the status of an import snapshot task**  
Use the [Get-EC2ImportSnapshotTask](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2ImportSnapshotTask.html) cmdlet as follows.

```
Get-EC2ImportSnapshotTask `
    -ImportTaskId import-snap-1234567890abcdef0 | 
        Format-List *,
           @{Name='SnapshotTaskDetail';Expression={ $_.SnapshotTaskDetail | Out-String }},
           @{Name='UserBucket';Expression={ $_.SnapshotTaskDetail.UserBucket | Out-String }}
```

The following is example output.

```
Description        : My server VM
ImportTaskId       : import-snap-1234567890abcdef0
SnapshotTaskDetail : Amazon.EC2.Model.SnapshotTaskDetail
Tags               : 
SnapshotTaskDetail : 
                     Description   : 
                     DiskImageSize : 2495933952
                     Encrypted     : 
                     Format        : VMDK
                     KmsKeyId      : 
                     Progress      : 
                     SnapshotId    : snap-111222333444aaabb
                     Status        : completed
                     StatusMessage : 
                     Url           : 
                     UserBucket    : Amazon.EC2.Model.UserBucketDetails
UserBucket         : 
                     S3Bucket : amzn-s3-demo-import-bucket
                     S3Key    : my-server-vm.vmdk
```

**To get the status of all import snapshot tasks**  
Use the [Get-EC2ImportSnapshotTask](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2ImportSnapshotTask.html) cmdlet as follows.

```
Get-EC2ImportSnapshotTask |
    Format-Table Description, ImportTaskId, 
        @{Name='Status';Expression={$_.SnapshotTaskDetail.Status}},
        @{Name='Progress';Expression={$_.SnapshotTaskDetail.Progress}},
        @{Name='SnapshotID';Expression={$_.SnapshotTaskDetail.SnapshotID}},
        @{Name='S3Key Source';Expression={$_.SnapshotTaskDetail.UserBucket.S3Key}}
```

The following is example output. You can display any additional fields that you need.

```
Description  ImportTaskId                  Status    Progress SnapshotID             S3Key Source
-----------  ------------                  ------    -------- ----------             ------------
My server VM import-snap-1234567890abcdef0 active    19                              my-server-vm.vmdk
My server VM import-snap-1234567890abcdef1 completed          snap-0450e071240000000 my-server-vm1.vmdk
My server VM import-snap-1234567890abcdef2 completed          snap-0bd3ea32601111111 my-server-vm2.vmdk
My server VM import-snap-1234567890abcdef3 deleted                                   my-server-vm3.vmdk
```

------

# Cancel an import snapshot task
<a name="cancel-import-task"></a>

After you start an import snapshot task using VM Import/Export, you can cancel the import operation if needed.

To describe your snapshot import tasks, see [Monitor an import snapshot task](check-status-import-task.md).

------
#### [ AWS CLI ]

**To cancel an import snapshot task**  
Use the [cancel-import-task](https://docs.aws.amazon.com/cli/latest/reference/ec2/cancel-import-task.html) command.

```
aws ec2 cancel-import-task \
    --import-task-id import-snap-1234567890abcdef0
```

------
#### [ PowerShell ]

**To cancel an import snapshot task**  
Use the [Stop-EC2ImportTask](https://docs.aws.amazon.com/powershell/latest/reference/items/Stop-EC2ImportTask.html) cmdlet.

```
Stop-EC2ImportTask `
    -ImportTaskId import-snap-1234567890abcdef0
```

------

# Create an EBS volume from an imported snapshot
<a name="import-snapshot-next-steps"></a>

You can create EBS volumes from an EBS snapshot. You can attach an EBS volume to an EC2 instance.

------
#### [ AWS CLI ]

**To create a volume and attach it to an EC2 instance**

1. Use the [describe-import-snapshot-tasks](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-import-snapshot-tasks.html) command to determine the ID of the snapshot that was created by the import task.

1. Use the following [create-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-volume.html) command to create a volume from the snapshot. You must select the Availability Zone of the instance to which you'll attach the volume.

   ```
   aws ec2 create-volume \
       --availability-zone us-east-1a \
       --snapshot-id snap-1234567890abcdef0
   ```

   The following is example output.

   ```
   {
       "AvailabilityZone": "us-east-1a",
       "VolumeId": "vol-1234567890abcdef0",
       "State": "creating",
       "SnapshotId": "snap-1234567890abcdef0"
   }
   ```

1. Use the following [attach-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/attach-volume.html) command to attach the EBS volume that you created in the previous step to one of your existing instances.

   ```
   aws ec2 attach-volume \
       --volume-id vol-1234567890abcdef0 \
       --instance-id i-1234567890abcdef0 \
       --device /dev/sdf
   ```

   The following is example output.

   ```
   {
       "AttachTime": "YYYY-MM-DDTHH:MM:SS.000Z",
       "InstanceId": "i-1234567890abcdef0",
       "VolumeId": "vol-1234567890abcdef0",
       "State": "attaching",
       "Device": "/dev/sdf"
   }
   ```

1. Mount the attached volume. For more information, see the documentation for the operating system for your instance.

------
#### [ PowerShell ]

**To create a volume and attach it to an EC2 instance**

1. Use the [Get-EC2ImportSnapshotTask](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2ImportSnapshotTask.html) cmdlet to determine the ID of the snapshot that was created by the import task.

1. Use the [New-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Volume.html) cmdlet to create a volume from the snapshot. You must select the Availability Zone of the instance to which you'll attach the volume.

   ```
   New-EC2Volume `
       -AvailabilityZone us-east-1a `
       -SnapshotId snap-1234567890abcdef0
   ```

   The following is example output.

   ```
   Attachments        : {}
   AvailabilityZone   : us-east-1a
   CreateTime         : 7/15/2025 3:37:56 PM
   Encrypted          : False
   FastRestored       : False
   Iops               : 3000
   KmsKeyId           : 
   MultiAttachEnabled : False
   Operator           : 
   OutpostArn         : 
   Size               : 41
   SnapshotId         : snap-1234567890abcdef0
   SseType            : 
   State              : creating
   Tags               : {}
   Throughput         : 125
   VolumeId           : vol-1234567890abcdef0
   VolumeType         : gp3
   ```

1. Use the [Add-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/Add-EC2Volume.html) cmdlet

   ```
   Add-EC2Volume `
       -VolumeId vol-1234567890abcdef0 `
       -InstanceId i-1234567890abcdef0 `
       -Device xvdb
   ```

   The following is example output.

   ```
   AssociatedResource    : 
   AttachTime            : 7/15/2025 3:47:20 PM
   DeleteOnTermination   : False
   Device                : xvdb
   InstanceId            : i-1234567890abcdef0
   InstanceOwningService : 
   State                 : attaching
   VolumeId              : vol-1234567890abcdef0
   ```

1. Mount the attached volume. For more information, see the documentation for the operating system for your instance.

------