Importing the image as a snapshot

Last Updated : Nov 26, 2024 |
Prolog information
Before you begin
  • Ensure that you get the bucket name for the image from the Amazon S3 console.
  • Ensure that you get the s3-key from the property page of image by selecting the image in the bucket.
  1. Go to cloudshell where you need to create a JSON file to import the image as a snapshot.
  2. Create a file to specify a bucket and path for your image and name the file containers.json
    ADDITIONAL INFORMATION:
    In the following example, replace s3-bucket-name with your bucket name and s3-key with your key.{
        "Description": "asbc-10.2-sample.raw",
        "Format": "raw",
        "UserBucket": {
            "S3Bucket": "s3-bucket-name",
            "S3Key": "s3-key"
        }
    }
  3. Run the import-snapshot command to import the image as a snapshot.
    ADDITIONAL INFORMATION:
    aws ec2 import-snapshot --disk-container file://containers.json
    This example uses a public Amazon S3 file. You can use the Amazon S3 console to change permissions settings on your bucket.
    The terminal displays the following message.{
        "SnapshotTaskDetail": {
            "Status": "active",
            "Format": "RAW",
            "DiskImageSize": 0.0,
            "UserBucket": {
                "S3Bucket": "s3-bucket-name",
                "S3Key": "asbc-10.2-sample.raw"
            },
            "Progress": "3",
            "StatusMessage": "pending"
        },
        "ImportTaskId": "import-snap-084974dea2495361a"
    }
    Note the ImportTaskId within the message.
  4. Run the describe-import-snapshot-tasks command to track the progress of the import.
    ADDITIONAL INFORMATION:
    Include the ImportTaskId from the earlier step.
    $ aws ec2 describe-import-snapshot-tasks --import-task-ids import-snap-084974dea2495361a
    The message shows the current status of the task. When complete, Status shows completed.
    {
        "ImportSnapshotTasks": [
            {
                "ImportTaskId": "import-snap-0b58889d6670f418f",
                "SnapshotTaskDetail": {
                    "DiskImageSize": 2598557696.0,
                    "Format": "VMDK",
                    "SnapshotId": "snap-06f1d84ffb7589160",
                    "Status": "completed",
                    "UserBucket": {
                        "S3Bucket": "asbc-pune-singapore",
                        "S3Key": "sbce-10.2.1.0-101-24795.vmdk"
                    }
                },
                "Tags": []
            }
        ]
    }
  5. Note the SnapshotId.