All Products
Search
Document Center

Elastic Compute Service:CreateImageComponent

Last Updated:Nov 14, 2024

Creates an image component. Image components are used to store the image template commands that are commonly used to create images.

Operation description

Usage notes

Take note of the following items:

  • You can create only custom image components.
  • Only Linux operating systems are supported. Set SystemType to Linux.
  • Only image build components are supported. Set ComponentType to Build.
  • You can use Dockerfile to edit the content of image components and pass the edited content into the Content parameter. The content size can be up to 16 KB. FROM commands cannot be used in image components. An image component supports up to 127 commands. For information about the supported commands, see Commands supported by Image Builder.

You can use image components to create image templates in the Elastic Compute Service (ECS) console, but cannot call API operations to create image templates from image components. For more information, see What is Image Builder.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:CreateImageComponentcreate
*ImageComponent
acs:ecs:{#regionId}:{#accountId}:imagecomponent/*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ResourceGroupIdstringNo

The ID of the resource group.

rg-bp67acfmxazb4p****
Tagarray<object>No

The tags.

objectNo
KeystringNo

The key of tag N. 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 contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey
ValuestringNo

The value of tag N. 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 contain http:// or https://. The tag value cannot start with acs:.

TestValue
NamestringNo

The name of the image component. The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with http:// or https://. The name can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-).

Note If you do not specify Name, the return value of ImageComponentId is used.
testComponent
DescriptionstringNo

The description. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This is description.
SystemTypestringNo

The type of the operating system supported by the image component.

Valid values:

  • Linux
  • Windows

Default value: Linux.

Linux
ComponentTypestringNo

The type of the image component. Only image building components and image test components are supported.

Valid values:

  • Build
  • Test

Default value: Build.

Note Image building components can be used only in image building templates. Image test components can be used only in image test templates.
Build
ContentstringNo

The content of the image component. The content consists of up to 127 commands.

RUN yum update -y
ClientTokenstringNo

The client token that is used to ensure the idempotency of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token 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
ComponentVersionstringNo

The version number of the image component, which is used together with the name of the image component. The version number is in the <major>.<minor>.<patch> format. Set <major>, <minor>, and <patch> to non-negative integers.

Default value: (x + 1).0.0, in which x is the maximum major version number of the image component.

null

Response parameters

ParameterTypeDescriptionExample
object
ImageComponentIdstring

The ID of the image component.

ic-bp67acfmxazb4p****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

{
  "ImageComponentId": "ic-bp67acfmxazb4p****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidCommand.ComponentImage component does not support component command.-
400InvalidName.Malformed%s-
400InvalidDescription.Malformed%s-
400InvalidSystemType.NotSupportedValue%s-
400InvalidComponentType.NotSupportedValue%s-
400InvalidContent.LengthExceeded%s-
400InvalidImageTemplateCommandSize.ExceededMaxNumber%s-
400InvalidImageTemplateCommand.NotSupported%s-
400InvalidCommandContent.RUN%s-
400InvalidCommandContent.ENV%s-
400InvalidCommandContent.WORKDIR%s-
400InvalidCommandContent.COPY%s-
400InvalidCommandContent.USER%s-
400InvalidCommandContent.CMD%s-
400InvalidCommandContent.ENTRYPOINT%s-
400MissingParameter.Content%s-
400EmptyCommandContent.RUN%s.If the RUN command exists in the template, you must specify RUN.
400EmptyCommandContent.ENV%s.If the ENV command exists in the template, you must specify ENV.
400EmptyCommandContent.LABEL%s.If the LABEL command exists in the template, you must specify LABEL.
400EmptyCommandContent.COPY%s.If the COPY command exists in the template, you must specify COPY.
400EmptyCommandContent.ENTRYPOINT%s.If the ENTRYPOINT command exists in the template, you must specify ENTRYPOINT.
400EmptyCommandContent.CMD%s.If the CMD command exists in the template, you must specify CMD.
400NotEmptyCommandContent.RESTART%s.If the RESTART command exists in the template, you must specify RESTART.
400EmptyCommandContent.WORKDIR%s.If the WORKDIR command exists in the template, you must specify WORKDIR.
400EmptyCommandContent.USER%s.If the USER command exists in the template, you must specify USER.
400QuotaExceed.ImageComponent%s.Image component quota exceeded in current region.
400InvalidParameter.Content%s.The image component content is invalid.
400InvalidImage.OsTypeUnsupportedThe specified base image does not support image building.-
400InvalidParameter.ComponentVersionThe specified ComponentVersion is invalid.The specified ComponentVersion is invalid.
403InvalidComponentVersion.ExistThe specified ComponentVersion does exist with the specified Name.The specified ComponentVersion does exist with the specified Name.
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.The specified resource group does not exist.
404NotSupportedCommand.FROM%s-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-10-10The Error code has changed. The request parameters of the API has changedView Change Details
2024-08-08The Error code has changedView Change Details
2023-03-28The Error code has changedView Change Details