All Products
Search
Document Center

Elastic Compute Service:CreateImageComponent

Last Updated:Jun 25, 2026

Creates an image component. Image components are used to store commonly used build template commands for image building.

Operation description

Operation description

Before you create an image component, take note of the following items:

  • Only custom image components can be created.

  • Component version numbers must be unique for the same component name. When using a component in a template, you can reference it by name and version number.

  • The content size of an image component cannot exceed 16 KB. For details about supported commands, see Commands supported by Image Builder.

For more information, see Image Builder overview.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:CreateImageComponent

create

*ImageComponent

acs:ecs:{#regionId}:{#accountId}:imagecomponent/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

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

cn-hangzhou

ResourceGroupId

string

No

The ID of the enterprise resource group.

rg-bp67acfmxazb4p****

Tag

array<object>

No

The tags.

object

No

Key

string

No

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

TestKey

Value

string

No

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

TestValue

RegionId

string

Yes

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

Note

If you do not specify Name, the ImageComponentId return value is used by default.

cn-hangzhou

ResourceGroupId

string

No

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

rg-bp67acfmxazb4p****

Name

string

No

The operating system supported by the component.

Valid values:

  • Linux

  • Windows

Default value: Linux.

testComponent

Description

string

No

The component type. Image build components and test components are supported.

Valid values:

  • Build

  • Test

Default value: Build.

Note

Build components can be used only in build templates, and test components can be used only in test templates.

This is description.

SystemType

string

No

The component content. The content consists of multiple commands and cannot exceed 16 KB. For more information about supported commands and command formats, see Commands supported by Image Builder.

Linux

ComponentType

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 you must make sure that the token is unique among different requests. The value of ClientToken can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Build

Content

string

No

The component version number. This parameter is used together with the component name. The format is major.minor.patch, where all values are non-negative integers.

Default value: (x+1).0.0, where x is the current maximum major version number of the component.

Tasks: - Name: HelloWorld Action: RunShellCommand Properties: commandContent: echo hello world

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 value of ClientToken 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

ComponentVersion

string

No

The version number of the component, which is used together with the component name. The format is major.minor.patch, and all values are non-negative integers.

Default value: (x+1).0.0, where x is the current maximum major version number of the component.

1.0.0

Response elements

Element

Type

Description

Example

object

ImageComponentId

string

The image component ID.

ic-bp67acfmxazb4p****

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidCommand.Component Image component does not support component command.
400 InvalidName.Malformed %s
400 InvalidDescription.Malformed %s
400 InvalidSystemType.NotSupportedValue %s
400 InvalidComponentType.NotSupportedValue %s
400 InvalidContent.LengthExceeded %s
400 InvalidImageTemplateCommandSize.ExceededMaxNumber %s
400 InvalidImageTemplateCommand.NotSupported %s
400 InvalidCommandContent.RUN %s
400 InvalidCommandContent.ENV %s
400 InvalidCommandContent.WORKDIR %s
400 InvalidCommandContent.COPY %s
400 InvalidCommandContent.USER %s
400 InvalidCommandContent.CMD %s
400 InvalidCommandContent.ENTRYPOINT %s
400 MissingParameter.Content %s
400 EmptyCommandContent.RUN %s. If the RUN command exists in the template, you must specify RUN.
400 EmptyCommandContent.ENV %s. If the ENV command exists in the template, you must specify ENV.
400 EmptyCommandContent.LABEL %s. If the LABEL command exists in the template, you must specify LABEL.
400 EmptyCommandContent.COPY %s. If the COPY command exists in the template, you must specify COPY.
400 EmptyCommandContent.ENTRYPOINT %s. If the ENTRYPOINT command exists in the template, you must specify ENTRYPOINT.
400 EmptyCommandContent.CMD %s. If the CMD command exists in the template, you must specify CMD.
400 NotEmptyCommandContent.RESTART %s. If the RESTART command exists in the template, you must specify RESTART.
400 EmptyCommandContent.WORKDIR %s. If the WORKDIR command exists in the template, you must specify WORKDIR.
400 EmptyCommandContent.USER %s. If the USER command exists in the template, you must specify USER.
400 QuotaExceed.ImageComponent %s. Image component quota exceeded in current region.
400 InvalidParameter.Content %s. The image component content is invalid.
400 InvalidImage.OsTypeUnsupported The specified base image does not support image building.
400 InvalidParameter.ComponentVersion The specified ComponentVersion is invalid. The specified ComponentVersion is invalid.
403 InvalidComponentVersion.Exist The specified ComponentVersion does exist with the specified Name. The specified ComponentVersion does exist with the specified Name.
403 InvalidOperation.NoPermissionCreateServiceLinkedRole You are not authorized to create Service-linked role. The system will automatically create it when the API is called for the first time. Check your RAM policies, and ensure that you are using the correct credentials. You are not authorized to create Service-linked role. The system will automatically create it when the API is called for the first time. Check your RAM policies, and ensure that you are using the correct credentials.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The specified resource group does not exist.
404 NotSupportedCommand.FROM %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.