Use shared images

Updated at:
Copy as MD

Create ECS instances, replace the operating system, or copy shared images received from other Alibaba Cloud accounts.

Considerations

Important

Alibaba Cloud does not guarantee the integrity or security of shared images. Before you use a shared image, verify that it comes from a trusted account. You assume all risks associated with using shared images.

Before you use a shared image, note the following items.

Item

Description

Fees

  • Shared images do not count against the custom image quota of the sharee account. No fees are charged for the shared images themselves.

  • If a shared image is derived from a paid image, the sharee is charged for the image when creating ECS instances from it.

See Image billing.

Limits

  • Sharees cannot delete or update shared images directly. To do so, copy the shared image as a custom image first.

  • If the resources used by a shared image become unavailable due to overdue payments or invalid keys, the image cannot be used to create ECS instances.

Permissions

  • To use a RAM user to create ECS instances from a shared image, the RAM user must have permissions to call the RunInstances or CreateInstance operation. See Create pay-as-you-go ECS instances.

  • To restrict a RAM user to create ECS instances only from images shared by a specific Alibaba Cloud account, attach the following policy to the RAM user:

    {
      "Version": "1",
      "Statement": [
        {
          "Action": [
            "ecs:RunInstances",
            "ecs:CreateInstance"
          ],
          "Effect": "Deny",
          "Resource": "*",
          "Condition": {
            "StringNotEquals": {
              "ecs:ImageOwnerId": "123456789012****"
            }
          }
        }
      ]
    }
    Note

    Replace the value of ImageOwnerId with the ID of an Alibaba Cloud account. In this example, "123456789012****" indicates that only images shared by this account can be used to create ECS instances.

Use a shared image to create ECS instances

Use the ECS console

Use a shared image to create one or more ECS instances with the same image environment.

  1. Go to ECS console - Images.

  2. In the upper-left corner of the page, select a region and resource group.地域

  3. Click the Shared Image tab, find the target shared image, and then click Create Instance in the Actions column.

    image

  4. The region and image are automatically populated. Configure other parameters such as Billing Method and Instance Type based on your business requirements.

    For other parameters, see Create an instance with Custom Launch.

    If you use an encrypted shared image, the system disks or data disks created from the image are automatically encrypted and cannot be changed to unencrypted. You must specify a service key or a customer master key (CMK) as the encryption key.

    image

Call an API operation

  1. Call the DescribeImages operation to query the IDs of available shared images.

  2. Call the RunInstances or CreateInstance operation with ImageId set to the ID of a shared image.

    Important

    If the shared image is encrypted, you must set Encrypted to true. Otherwise, instance creation may fail.

Replace the operating system with a shared image

Use the ECS console

Replace the operating system (system disk) of an ECS instance with a shared image.

In the Replace Operating System section of the Change Operating System page, select Shared Image and then select a shared image. See Replace the operating system (system disk).

Call an API operation

  1. Call the DescribeImages operation to query the IDs of available shared images.

  2. Call the ReplaceSystemDisk operation with ImageId set to the ID of a shared image to replace the operating system (system disk).

    Important

    If the shared image is encrypted, you must set Encrypted to true to encrypt the new system disk. Otherwise, the replacement may fail.

Copy a shared image

Use the ECS console

As a sharee, you can only use a shared image to create ECS instances. To delete or update a shared image, copy it first. The copy appears as a custom image in the same region.

  1. On the Shared Image tab, find the target shared image and click Copy Image in the Actions column.

    image

  2. In the Copy Image dialog box, configure the parameters.

    • Set Copy Mode to Copy or Copy and Encrypt.

    • For Destination Region, you can select only the region in which the shared image resides.

      Note

      Shared images can only be copied within the same region. To copy a shared image to a different region, first copy it in the current region, and then copy the resulting custom image to the target region.

    For other parameters, see Copy a custom image.

  3. (Optional) View the image copy on the Custom Images tab.

Call an API operation

  1. Call the DescribeImages operation to query the IDs of available shared images.

  2. Call the CopyImage operation with ImageId set to the ID of a shared image.

    Important

    If the shared image is encrypted, you must set Encrypted to true to encrypt the image copy. Otherwise, the copy may fail.

References