Imports a local image file to Elastic Compute Service (ECS) as a custom image that appears in the specified region. You can then use the imported image to create ECS instances (RunInstances) or replace the system disk of an instance (ReplaceSystemDisk).
Operation description
Operation description
When you call this operation, take note of the following items:
-
You must upload the image file to Object Storage Service (OSS) in advance. For more information, see Upload objects.
-
To prevent ECS instances created from the imported custom image from failing to start due to operating system issues on some servers, virtual machines, or cloud hosts, check whether you need to install the virtio driver on the source server before importing the image. For more information, see Install a virtio driver.
-
When you import an image for the first time, you must use Resource Access Management (RAM) to authorize ECS to access your OSS bucket. Otherwise, the
NoSetRoletoECSServiceAccountorInvalidOperation.CloudBoxImageImportRoleRequirederror is reported. The following two scenarios apply:-
Import an image file without using CloudBox: You can complete RAM authorization with one click in the RAM console. For RAM authorization page, see Cloud resource access authorization. You can also manually complete RAM authorization. The following policies and permissions are required for some operations. For more information, see Account access control.
-
Create a role named
AliyunECSImageImportDefaultRole(this exact name is required, otherwise the image import fails). The policy for the role is:{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "ecs.aliyuncs.com" ] } } ], "Version": "1" } -
Attach the system policy
AliyunECSImageImportRolePolicyto the role. You can also create a custom policy that must include the following permissions:{ "Version": "1", "Statement": [ { "Action": [ "oss:GetObject", "oss:GetBucketLocation", "oss:GetBucketInfo" ], "Resource": "*", "Effect": "Allow" } ] }
-
-
Import an image file by using CloudBox: You can complete RAM authorization with one click in the RAM console. For RAM authorization page, see Cloud resource access authorization. You can also manually complete RAM authorization. The following policies and permissions are required for some operations. For more information, see Account access control.
-
Create a role named
AliyunECSCloudBoxImageImportDefaultRole(this exact name is required, otherwise the image import fails). The policy for the role is:{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "ecs.aliyuncs.com" ] } } ], "Version": "1" } -
Attach the system policy
AliyunECSCloudBoxImageImportRolePolicyto the role. You can also create a custom policy that must include the following permissions:{ "Version": "1", "Statement": [ { "Action": [ "oss-cloudbox:GetObject", "oss-cloudbox:GetBucketLocation", "oss-cloudbox:GetBucketInfo" ], "Resource": "*", "Effect": "Allow" } ] }
-
-
-
You cannot delete an image that is being imported. You can only call CancelTask to cancel the image import task.
-
The region to which the image is imported must be the same as the region of the OSS bucket to which the image file is uploaded.
-
Valid values of N in the
DiskDeviceMapping.Nparameter: 1 to 17. N=1 indicates the system disk. N=2 to 17 indicates data disks. When N is greater than 17, the system automatically ignores the value. -
When the
Architectureparameter is set toarm64, or thePlatformparameter is set toCentOS Stream,Anolis,AlmaLinux,UOS,Kylin, orRocky Linux, take note of the following items:-
To enable the imported image to support password configuration or key pair modification, the image must meet the following conditions:
-
The operating system kernel must support the
CONFIG_FW_CFG_SYSFSfeature. Linux community kernels later than version 4.6 support this feature by default. CentOS kernels later than version 3.10.0-826.el7 support this feature by default. You can run thegrep -nr CONFIG_FW_CFG_SYSFS /boot/config-$(uname -r)command on the server that corresponds to the image. If the output containsCONFIG_FW_CFG_SYSFS=y, the kernel in the image supports theCONFIG_FW_CFG_SYSFSfeature. -
The latest version of Alibaba Cloud cloud-init is installed on the operating system. Cloud-init 19.1 must Milvus version 19.1.3 or later. Cloud-init 0.7.6a on some earlier operating systems must Milvus version 0.7.6a15 or later. For more information, see Install cloud-init.
-
The operating system must support the SHA-512 encryption algorithm.
-
-
To enable the imported image to support disk resizing and file system resizing, the image must meet the following conditions:
-
The operating system kernel version must be later than 3.6.
-
The growpart command is supported. To support this command, install the
cloud-utils-growpartpackage. The installation method varies depending on the operating system. For more information, see Resize partitions and file systems (Linux). -
The resize2fs command is supported. To support this command, install the
e2fsprogspackage. This package is installed by default on the operating system. If it is not installed, install it manually. -
The latest version of Alibaba Cloud cloud-init is installed on the operating system. Cloud-init 19.1 must Milvus version 19.1.3 or later. Cloud-init 0.7.6a on some earlier operating systems must Milvus version 0.7.6a15 or later. For more information, see Install cloud-init.
-
-
-
If the system architecture of the custom image that you want to import is arm64, set the RTC clock to use the UTC time standard. For more information, see Linux time and time zone description.
-
We strongly recommend that you configure image detection parameters when importing an image. This helps the system optimize your image. For more information, see Overview of image detection.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:ImportImage |
update |
*Image
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the source custom image. You can call DescribeRegions to query the most recent region list. |
cn-hangzhou |
| ImageName |
string |
No |
The image name. The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character and cannot start with |
ImageTestName |
| Description |
string |
No |
The description of the image. The description must be 2 to 256 characters in length and cannot start with |
TestDescription |
| Architecture |
string |
No |
The system architecture. Valid values:
Default value: x86_64. |
x86_64 |
| OSType |
string |
No |
The operating system type. Valid values:
Default value: linux. |
linux |
| Platform |
string |
No |
The operating system distribution. Valid values:
Default value: Others Linux. |
Aliyun |
| BootMode |
string |
No |
The boot mode of the image. Valid values:
Default value: BIOS. If Important
To prevent instances from failing to start due to an unsupported boot mode, make sure that you understand the boot mode supported by the target image before you specify this parameter. For more information about image boot modes, see Image boot modes. |
BIOS |
| RoleName |
string |
No |
The name of the RAM role used to import the image. |
AliyunECSImageImportDefaultRole |
| LicenseType |
string |
No |
The license type. This parameter specifies the authorization mode when instances are created by calling RunInstances with this image. This value takes effect only for Windows Server images. Valid values:
Default value: Aliyun. |
BYOL |
| ResourceGroupId |
string |
No |
The ID of the enterprise resource group to which the imported image belongs. |
rg-bp67acfmxazb4p**** |
| DiskDeviceMapping |
array<object> |
No |
The information list of the custom image to create. |
|
|
object |
No |
The information list of the custom image to create. |
||
| DiskImSize |
integer |
No |
The size of the custom image. Unit: GiB. The space consists of the system disk and data disks. Make sure that the system disk space is greater than or equal to the size of the imported image file. Valid values:
After you upload the source image file to OSS, you can view the image file size in the OSS bucket. Note
This parameter will be deprecated. For better compatibility, use |
80 |
| Device |
string |
No |
The device name of DiskDeviceMapping.N.Device in the custom image. Note
This parameter will be deprecated. For better code compatibility, do not use this parameter. |
null |
| OSSBucket |
string |
No |
The OSS bucket where the image file is stored. Note
Before importing an image to this OSS bucket for the first time, add the RAM authorization policy as described in the Operation description section of this topic. Otherwise, the |
ecsimageos |
| Format |
string |
No |
The image format. Valid values:
Default value: empty, which indicates that Alibaba Cloud automatically detects the image format and uses the detected format. |
QCOW2 |
| OSSObject |
string |
No |
The name (key) of the image file stored in the OSS bucket after the image is uploaded to OSS. |
CentOS_5.4_32.raw |
| DiskImageSize |
integer |
No |
The space size of the custom image after the image is imported. The space consists of the system disk and data disks. Make sure that the system disk space is greater than or equal to the size of the imported image file. Valid values:
After you upload the source image file to OSS, you can view the image file size in the OSS bucket. |
80 |
| Tag |
array<object> |
No |
The tag list of the image. |
|
|
object |
No |
The tag list of the image. |
||
| Key |
string |
No |
The tag key of the image. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot start with |
TestKey |
| Value |
string |
No |
The tag value of the image. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with |
TestValue |
| DetectionStrategy |
string |
No |
The image detection strategy. If this parameter is not specified, detection is not triggered. Only the Standard detection mode is supported. Note
Most Linux/Windows versions are supported. For more information about image detection items and operating system limitations, see Overview of image detection and Operating system limitations for image detection. |
Standard |
| StorageLocationArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the CloudBox, which uniquely identifies the cloud storage location. Note
You need to specify this parameter only when you import an image file from OSS on CloudBox. If you are not using OSS on CloudBox, do not set this parameter. For more information, see What is OSS on CloudBox. The correct ARN format is: |
arn:acs:cloudbox:cn-hangzhou:123456:cloudbox/cb-xx***123 |
| DryRun |
boolean |
No |
Specifies whether to perform only a dry run. Valid values:
Default value: false. |
false |
| Features |
object |
No |
The image feature-related properties. |
|
| NvmeSupport |
string |
No |
Specifies whether the image supports NVMe.
Note
By default, imported images are considered as not supporting the NVMe protocol. If you plan to run the image on instance types that support NVMe (such as c8i and r9i), make sure that the image has a built-in NVMe driver and explicitly set this parameter to supported. |
supported |
| ImdsSupport |
string |
No |
The metadata access mode of the image. Valid values:
Default value: v1. |
v2 |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but make sure that the token is unique among different requests. The ClientToken value can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
123e4567-e89b-12d3-a456-426655440000 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| ImageId |
string |
The image ID. |
m-bp67acfmxazb4p**** |
| TaskId |
string |
The ID of the image import task. |
t-bp67acfmxazb4p**** |
| RegionId |
string |
The region ID. |
cn-hangzhou |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"ImageId": "m-bp67acfmxazb4p****",
"TaskId": "t-bp67acfmxazb4p****",
"RegionId": "cn-hangzhou"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | UnsupportedSuffix.OSSObject | The specified OSS object suffix is not supported. | The specified OSS object suffix is not supported. |
| 400 | MissingParameter | An input parameter "RegionId" that is mandatory for processing the request is not supplied. | |
| 400 | InvalidImageName.Malformed | The specified Image name is wrongly formed. | The specified image name is invalid. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with acs: or aliyun. It can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-). It cannot contain http:// or https://. |
| 400 | InvalidOSSObject.Malformed | The specified OSS object is wrongly formed. | The specified OSS object is invalid. |
| 400 | InvalidOSSBucket.Malformed | The specified OSS bucket is wrongly formed. | |
| 400 | InvalidOSSObject.Size | The specified OSS object size is zero. | The specified OSSObject is empty |
| 400 | InvalidDescription.Malformed | The specified Image description is wrongly formed. | The image description is invalid. |
| 400 | InvalidArchitecture.Malformed | The specified Architecture is wrongly formed. | The specified Architecture parameter is invalid. |
| 400 | InvalidPlatform.Malformed | The specified Platform is wrongly formed. | The specified platform is invalid. |
| 400 | InvalidOSType.Malformed | The specified OSType is wrongly formed. | The specified OS type is invalid. |
| 400 | InvalidImageName.Duplicated | The destination image is exist. | |
| 400 | InvalidImageSize | %s | The specified image size is invalid. |
| 400 | InvalidDataDiskSize | The specified DiskDeviceMapping.N.DiskImSize should be in the specified range. | The specified DiskDeviceMapping.N.DiskImSize parameter is invalid. |
| 400 | InvalidImageFormat.Malformed | The specified Image Format is wrongly formed. | The specified image format is invalid. |
| 400 | InvalidRegionId.NotFound | The specified RegionId does not exist. | |
| 400 | InvalidRegion.NotSupport | The specified region does not support image import or export. | The specified region does not support the operation. |
| 400 | InvalidOSSBucket.NotFound | The specified OSS bucket does not exist in this region. | The specified bucket does not exist. |
| 400 | InvalidOSSObject.NotFound | The specified OSS object does not exist in this region. | |
| 400 | InvalidOSSObject.NeedRestore | The specified OSS object is a archive object, need restore first. | |
| 400 | InvalidOSSBucket.NotMatched | The specified OSS bucket is incorrect, %s. | The specified DiskDeviceMapping.N.OSSBucket parameter is invalid. For more information, see the return value of the %s placeholder in the error message. |
| 400 | InvalidLicenseType.NotSupported | The specified LicenseType is not supported. | |
| 400 | InvalidLicenseType.BYOLOnly | Only BYOL LicenseType is supported for the current platform provided. | |
| 400 | InvalidOSSBucket.FlowLimit | %s | |
| 400 | InvalidImageFormat.RegionNotSupported | The specified image format is not supported in current region. | |
| 400 | InvalidBootMode.Malformed | The specified parameter "BootMode" is malformed. | |
| 400 | InvalidParameter.DetectionStrategy | The specified parameter DetectionStrategy is invalid. | |
| 400 | InvalidBootMode.NotSupport | The specified parameter BootMode is not supported for current image architecture. | The current image architecture does not support setting this boot mode. |
| 400 | DRYRUN.SUCCESS | This request is a dryrun request with successful result. | The request is checked and determined as valid. |
| 400 | InvalidClientToken.Malformed | The specified parameter clientToken is not valid. | The specified ClientToken parameter does not meet the format requirements. The parameter must contain only ASCII characters and cannot exceed 64 characters in length. |
| 400 | InvalidParameter.FeaturesImdsSupport | The specified parameter Features.ImdsSupport is not supported. | The specified parameter Features.ImdsSupport is not supported. |
| 400 | Account.Arrearage | Your account has an outstanding payment. | Your account has overdue payments. |
| 403 | ImageIsImporting | The specified Image is importing. | |
| 403 | QuotaExceed.Image | The Image Quota exceeds. | |
| 403 | ImportImageFailed | Importing image is failed, Please contact the administrator. | The image cannot be imported. Contact your system administrator. |
| 403 | UserNotInTheWhiteList | The user is not in the white list of importing image. | |
| 403 | NoSetRoletoECSServiceAcount | ECS service account Have no right to access your OSS.please attach a role of access your oss to ECS service account. | |
| 403 | InvalidParameter.Malformed | The specified parameter "DiskDeviceMapping.n.Device " is not valid. | |
| 403 | MissingParameter.DiskDeviceMapping | The specified parameter DiskDeviceMapping is not supplied. | A parameter that starts with DiskDeviceMapping must be specified. |
| 403 | InvalidOSS.NotAuthorized | The specified OSS bucket or object is not allowed to access. | You do not have the permission to access the specified OSS bucket and object. |
| 403 | InvalidBlockSize.NotSupport | %s | The partition size of the image file is not supported. |
| 403 | InvalidImageFormat.Malformed | %s | |
| 403 | ImageCheckUnsupported.WindowsImage | Image check is unsupported for windows image. | |
| 403 | InvalidVHDImage.IncorrectSize | The specified size of the VHD image does not meet the 'header.MaxTableEntries * header.BlockSize' specification. | The size of the specified VHD image does not meet the header.MaxTableEntries × header.BlockSize size limit. |
| 403 | InvalidOSSBucket.EncryptUnsupported | Accessing objects from encrypted OSS bucket is not supported. | You cannot read objects from encrypted OSS buckets. |
| 403 | InvalidArchitecture.PlatformUnsupported | The OS platform you selected does not support the specified architecture. | The selected operating system does not support the specified architecture type. |
| 403 | InvalidAccountStatus.OSSDisabled | OSS is disabled due to invalid account status. | OSS is disabled due to an invalid account status. |
| 403 | InvalidStorageLocation.NotFound | The specified cloud box storage location %s could not be found. | The specified cloud box storage location could not be found. |
| 403 | InvalidOperation.CloudBoxImageImportRoleRequired | The role for cloud box image import is not set to the ECS service. | The role for cloud box image import is not set to the ECS service. |
| 403 | InvalidOperation.CloudBoxImageImportUnsupported | Importing cloud box images is not supported. | Importing cloud box images is not supported. |
| 403 | TagKey.Duplication | The TagKey has duplication with others, case-insensitive. | Duplicate values exist in the specified Tag.N.Key parameter. The value of this parameter is not case sensitive. Check whether duplicate parameter values are passed in. |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The specified resource group does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.