All Products
Search
Document Center

Elastic Compute Service:CreateImageComponent

Last Updated:Sep 29, 2024

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

Operation description

Take note of the following items:

  • Only custom image components can be created.
  • The images must run Linux operating systems. This indicates that you must set SystemType to Linux.
  • You must set the image component type to image build component by setting the ComponentType parameter to Build.
  • You can use Dockerfile to edit the content of image components, and then pass the edited content into the Content parameter. The content size must not be greater than 16 KB. FROM commands cannot be used in image components. An image component supports up to 127 commands. For information about supported commands, see Description of 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 use image components to create image templates. For more information, see Overview of Image Builder.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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 component name. The name must be 2 to 128 characters in length. The name must start with a letter but cannot start with http:// or https://. The name can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-).

Note If you do not configure 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 operating system type supported by the image component. Only Linux is supported. Set the value to Linux.

Default value: Linux.

Linux
ComponentTypestringNo

The type of the image component. Only image build components are supported. Set the value to Build.

Default value: Build.

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

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.
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-08-08The Error code has changedView Change Details
2023-03-28The Error code has changedView Change Details