CreateImage_云服务器 ECS_API文档

插件下载了解更多
VS Code 插件
安装插件之前,确保已安装 VS Code安装插件之前,确保已安装 VS Code
Alibaba Cloud Developer Toolkit is a collection of extensions that can help access Alibaba Cloud services in Visual Studio Code.
JetBrains 插件
安装插件之前,确保已安装 JetBrains IDE安装插件之前,确保已安装 JetBrains IDE
The Alibaba Cloud Developer Toolkit for JetBrains makes it easier to access Alibaba Cloud services.

接口说明

注意事项

  • 本接口为异步接口,创建自定义镜像请求发送成功后会返回镜像 ID,镜像的创建不是立即完成的,需要调用 DescribeImage 查看镜像信息,当返回信息中的状态为Available时代表镜像创建成功并可用。更多信息,请参见自定义镜像概述

  • 查询 ECS 实例信息时,如果返回数据中包含{"OperationLocks": {"LockReason" : "security"}},则禁止创建自定义镜像。

  • 建议在创建镜像时配置镜像检测参数DetectionStrategy,有助于系统帮助优化您的镜像。更多信息,请参见镜像检测概述

以下描述了三种通过该接口创建自定义镜像的方法。请求参数的优先级为:InstanceId > DiskDeviceMapping > SnapshotId,若您的请求中同时含有两个及以上参数,默认以优先级更高的参数为准创建镜像。

  • 根据实例创建自定义镜像:指定实例 ID(InstanceId)。

    • 实例的状态必须为运行中(Running)或者已停止(Stopped)。
    • 接口调用成功后,实例的每块云盘均会新增一份快照。

    注意 由于运行中的实例存在缓存数据未落盘的情况,可能导致创建的自定义镜像数据与实例数据不完全一致,因此建议您停止实例( StopInstances )后创建镜像。

  • 根据快照创建自定义镜像(指定的快照不能是 2013 年 7 月 15 日(含)之前创建的快照。)

    • 使用系统盘快照创建自定义镜像:只需指定实例系统盘的快照 ID(SnapshotId)。
    • 使用系统盘快照和数据盘快照创建自定义镜像:这需要建立几块云盘的数据关联(DiskDeviceMapping)。
      • 系统盘快照只能被指定一个。
      • 数据盘快照可以指定多个,最多不能超过 16 块。不指定DiskDeviceMapping.N.SnapshotId时会创建一个默认容量的空数据盘。
说明 当释放实例时,系统盘将被转为按量付费数据盘保留。该盘创建的快照不支持创建自定义镜像,请根据需要在实例释放前制作自定义镜像。

流控信息

请求速率为1000/60(s)。更多流控信息,请前往配额中心查看

授权信息

如下是此API对应的授权信息,用于RAM权限策略语句的Action元素中,为RAM用户或RAM角色授予调用此API的权限。请通过 RAM 访问控制设置,使用方法可参考访问控制帮助文档

具体说明如下:展开详情

操作访问级别资源类型条件关键字关联操作
ecs:CreateImage
Create
Image
acs:ecs:{#regionId}:{#accountId}:image/*
Instance
acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}
Snapshot
acs:ecs:{#regionId}:{#accountId}:snapshot/{#snapshotId}

请求参数

字段名称字段详情
RegionIdstring

镜像所在的地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

示例值:cn-hangzhou参考取值来源:
    DescribeRegions
SnapshotIdstring

用于创建自定义镜像的快照 ID。展开详情

示例值:s-bp17441ohwkdca0****参考取值来源:
    CopySnapshot
    CreateSnapshot
    DescribeSnapshots
InstanceIdstring

实例 ID。根据实例创建自定义镜像时,必须指定该参数。

示例值:i-bp1g6zv0ce8oghu7****参考取值来源:
    RunInstances
    StopInstances
    StartInstances
    CreateInstance
    RebootInstances
    DescribeInstances
    ModifyManagedInstance
    RenewReservedInstances
    DetachInstanceRamRole
    AttachInstanceRamRole
    DeregisterManagedInstance
    PurchaseReservedInstancesOffering
ImageNamestring

镜像名称。长度为 2~128 个英文或中文字符。必须以大小写字母或中文开头,不能以 http://和 https://开头。可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。

示例值:TestCentOS参考取值来源:
    DescribeImages
ImageFamilystring

镜像族系名称。长度为 2~128 个英文或中文字符。必须以大小写字母或中文开头,不能以 aliyun 和 acs:开头,不能包含 http://或者 https://。可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。

示例值:hangzhou-daily-update参考取值来源:
    DescribeImages
ImageVersionstring

镜像版本。展开详情

示例值:2017011017参考取值来源:
    DescribeImages
Descriptionstring

镜像的描述信息。长度为 2~256 个英文或中文字符,不能以 http://或 https://开头。

示例值:ImageTestDescription
Platformstring

操作系统,指定数据盘快照做镜像的系统盘后,需要通过 Platform 确定系统盘的操作系统发行版。取值范围:展开详情

示例值:CentOS
BootModestring

修改镜像的启动模式。取值范围:展开详情

示例值:BIOS枚举值:BIOSUEFIUEFI-Preferred
Architecturestring

系统架构,指定数据盘快照做镜像的系统盘后,需要通过 Architecture 确定系统盘的系统架构。取值范围:展开详情

示例值:x86_64
ClientTokenstring

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多信息,请参见如何保证幂等性

示例值:123e4567-e89b-12d3-a456-426655440000
ResourceGroupIdstring

自定义镜像所在的资源组 ID。如果不设置该参数值,创建的镜像属于默认资源组。展开详情

示例值:rg-bp67acfmxazb4p****参考取值来源:
    DescribeSecurityGroups
DiskDeviceMappingarray<object>

创建自定义镜像使用的云盘和快照信息集合。如果需要根据系统盘快照和数据盘快照创建自定义镜像,请使用该参数指定快照。

子级条数 <= 17
Tagarray<object>

标签列表。

子级条数 <= 20
DetectionStrategystring

镜像检测策略,不配置此参数时不触发检测。仅支持标准(Standard)检测模式。 展开详情

示例值:Standard
Featuresobject

镜像特性相关属性。

返回参数

字段名称字段详情
ImageIdstring

镜像 ID。

示例值:m-bp146shijn7hujku****
RequestIdstring

请求 ID。

示例值:C8B26B44-0189-443E-9816-*******

返回示例

错误码

全局错误码
HTTP 状态码错误码错误信息操作
400
InvalidImageName.Malformed
The specified Image name is wrongly formed.诊断
400
InvalidImageName.Duplicated
The specified image name is already in use.诊断
400
InvalidDescription.Malformed
The specified description is wrongly formed.诊断
400
InvalidImageVersion.Malformed
The specified ImageVersion is wrongly formed.诊断
400
IncorrectInstanceStatus
The current status of the instance does not support this operation.诊断
400
InstanceLockedForSecurity
The specified operation is denied as your instance is locked for security reasons.诊断
400
InvalidDevice.Malformed
The specified parameter DiskDeviceMapping.n.Device is not valid.诊断
400
MissingParameter
The input parameter SnapshotId or InstanceId or DiskDeviceMapping that is mandatory for processing this request is not supplied.诊断
400
InvalidSize.ValueNotSupported
The specified parameter DiskDeviceMapping.n.Size beyond the permitted range.诊断
400
InvalidDevice.InUse
The specified parameter DiskDeviceMapping.n.Device has been occupied.诊断
400
OperationDenied
The specified parameter DiskDeviceMapping.n.SnapshotId does not contain system disk snapshot.诊断
400
InvalidDiskCategory.CreateImage
The specified diskCategory is not allowed to create image.诊断
400
InvalidArchitecture.Malformed
The specified Architecture is wrongly formed.诊断
400
InvalidPlatform.Malformed
The specified Platform is wrongly formed.诊断
400
InvalidParameter.AllEmpty
%s诊断
400
InvalidParameter.DiskType
The specified disk type which has kms key can't convert to system disk.诊断
400
Duplicate.TagKey
The Tag.N.Key contain duplicate key.诊断
400
InvalidTagKey.Malformed
The specified Tag.n.Key is not valid.诊断
400
InvalidTagValue.Malformed
The specified Tag.n.Value is not valid.诊断
400
InvalidInstance.NotFoundSystemDisk
The specified instance does not have system disk.诊断
400
InvalidImageFamily.Malformed
The format of the specified image family is invalid.诊断
400
ImageQuotaExceed.ImageFamily
The specified image family exceeds the maximum number of images for one image family.诊断
400
ImageFamilyQuotaExceed
The number of image families exceeds the limit in the region.诊断
400
InvalidDiskType.ValueNotSupported
The specified disk type is not supported.诊断
400
IdempotenceParamNotMatch
Request uses a client token in a previous request but is not identical to that request.诊断
400
InvalidBootMode.NotSupport
The specified parameter BootMode is not supported for current image architecture.诊断
400
InvalidParameter.FeaturesImdsSupport
The specified parameter Features.ImdsSupport is not supported.诊断
400
InvalidOperation.DiskCategoryUnsupported
The current category of the disk does not support this operation.诊断
403
IncorrectDiskStatus.NeverAttached
The specified disk has never been attached to instance.诊断
403
InvalidSnapshotId.NotReady
The current status of the DiskDeviceMapping.n.SnapshotId or SnapshotId does not support this operation.诊断
403
InvalidSnapshot.TooOld
This operation is denied because the specified snapshot by DiskDeviceMapping.n.SnapshotId or SnapshotId is created before 2013-07-15.诊断
403
OperationDenied
The specified snapshot is not allowed to create image.诊断
403
QuotaExceed.Image
The Image Quota exceeds.诊断
403
InvalidParamter.Conflict
The specified same token is trying to make requests with different parameters.诊断
403
InvalidAccountStatus.NotEnoughBalance
Your account does not have enough balance.诊断
403
InvalidAccountStatus.SnapshotServiceUnavailable
Snapshot service has not been opened yet.诊断
403
UserNotInTheWhiteList
The user is not in the white list of create image by data disk snapshot.诊断
403
IncorrectDiskStatus.Invalid
Device status is invalid, please restart instance and try again.诊断
403
OperationDenied.InvalidSnapshotCategory
%s诊断
403
QuotaExceed.Snapshot
The snapshot quota exceeds.诊断
403
IncorrectDiskStatus.Transferring
The specified device is transferring, you can retry after the process is finished.诊断
403
IncorrectDiskStatus
The current disk status does not support this operation.诊断
403
InvalidSystemSnapshot.Missing
%s诊断
403
IncorrectDiskStatus.CreatingSnapshot
A previous snapshot creation is in process.诊断
403
InvalidParameter.KMSKeyId.CMKUnauthorized
The CMK needs to be added ECS tag.诊断
403
InvalidParameter.KMSKeyId.CMKNotEnabled
The CMK needs to be enabled.诊断
403
InvalidParameter.KMSKeyId.KMSUnauthorized
ECS service have no right to access your KMS.诊断
403
QuotaExceed.Tags
%s诊断
403
InvalidSnapshotCategory.NotSupportImageCreation
The specified snapshot category does not support create image.诊断
403
TooManySnapshot.Unfinished
There are too many snapshots being created, please wait for them to be created done.诊断
403
HibernationConfigured.InstanceOperationForbidden
The operation is not permitted due to limit of the hibernation configured instance.诊断
403
SnapshotNotReady
The specified snapshot is not ready.诊断
403
IncorrectInstanceStatus.NeedRestart
The instance needs to be restarted after adding a disk in a shutdown status.诊断
403
QuotaExceed.ConcurrentSnapshotQuota
The number of snapshots being created for the disk %s has exceeded the concurrent quota (%s). Please wait for the previous snapshots to complete before trying again.诊断
404
InvalidSnapshotId.NotFound
The specified SnapshotId does not exist.诊断
404
InvalidInstanceId.NotFound
The specified instance %s does not exist.诊断
404
InvalidResourceGroup.NotFound
The ResourceGroup provided does not exist in our records.诊断
500
InternalError
The process of creating snapshot has failed due to some unknown error.诊断

变更历史

变更时间变更内容概要操作
2025-02-27
变更错误码400
变更错误码404
2025-01-16
变更错误码400
2024-12-05
变更错误码400
新增请求参数Features
2024-10-22
变更错误码403
2024-06-12
变更错误码400
2024-05-09
删除返回参数
  • 1
  • 2
  • 10 条/页

相关示例