This topic describes how to call the ModifyImageSharePermission operation by using Alibaba Cloud command-line interface (CLI) to manage the share permission of an image.

Background information

You can call the ModifyImageSharePermission operation to manage the share permission of an image. After you share a custom image with another Alibaba Cloud account, the account can use the shared image to create ECS instances (RunInstances) or replace the system disk of an ECS instance (ReplaceSystemDisk). For more information, see ModifyImageSharePermission.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeImages operation to query the ID of the image that you want to share.
    In this example, query the ID of an image by using its name.
    aliyun ecs DescribeImages --RegionId cn-hangzhou --ImageName demoName --output cols=Images.Image[].ImageId
    Sample response:
    Images.Image[].ImageId
    ----------------------
    [m-bp1503ydxxrppctb****]
  2. Modify the share permission of the image to share it with another Alibaba Cloud account.
    aliyun ecs ModifyImageSharePermission --RegionId cn-hangzhou --ImageId m-bp1503ydxxrppctb**** --AddAccount.1 1234567890

Result

{
    "RequestId":"C8B26B44-0189-443E-9816-D951F59623A9"
}