Creates an image template. Image templates can be used to create images.

Description

You can use image templates to customize image content and create images across regions and accounts. When you call this operation, take note of the following items:

  • You can create only custom image templates.
  • You can configure only public, custom, or shared Linux images or image families as the source images to create custom image templates.
  • When you use an image template to create an image, you must create an intermediate Elastic Compute Service (ECS) instance to help create the image. The intermediate instance is billed on a pay-as-you-go basis. For more information, see Pay-as-you-go.

For the BuildContent parameter that specifies the content of image templates, take note of the following items:

  • If the BuildContent value contains FROM commands, the values of BaseImageType that specifies the type of the source image and BaseImage that specifies the source image are overridden by the FROM commands.
  • If the BuildContent value does not contain FROM commands, the system adds the FROM command that consists of the BaseImageType and BaseImage values to the first line of the template content in the format of <BaseImageType>:<BaseImage>.
  • You can use Dockerfile to edit the content of image templates and then pass the edited content into the BuildContent parameter. The content cannot be greater than 16 KB in size, and can contain up to 127 commands. For information about the commands that are supported, see Commands supported by Image Builder.

You can use image components to create image templates in the ECS console, but cannot call API operations to use image components to create image templates. For more information, see Overview.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateImagePipeline

The operation that you want to perform. Set the value to CreateImagePipeline.

RegionId String Yes cn-hangzhou

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

ResourceGroupId String No rg-bp67acfmxazb4p****

The ID of the resource group to which to assign the image template.

BaseImageType String Yes IMAGE

The type of the source image. Valid values:

  • IMAGE: custom image
  • IMAGE_FAMILY: image family
BaseImage String Yes m-bp67acfmxazb4p****

The source image.

  • When you set BaseImageType to IMAGE, set BaseImage to the ID of a custom image.
  • When you set BaseImageType to IMAGE_FAMILY, set BaseImage to the name of an image family.
Name String No testImagePipeline

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

Note If you do not specify the Name parameter, the return value of ImagePipelineId is used by default.
Description String No This is description.

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

ImageName String No testImageName

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

The system generates the final complete image name that consists of the prefix and the ID of the image build task (ExecutionId) in the format of {ImageName}_{ExecutionId}.

VSwitchId String No vsw-bp67acfmxazb4p****

The ID of the vSwitch.

If you do not specify this parameter, a virtual private cloud (VPC) and a vSwitch are created by default. Make sure that the VPC quota in your account is sufficient. For more information, see Limits.

InstanceType String No ecs.g6.large

The instance type of the instance. You can call the DescribeInstanceTypes operation to query instance types.

If you do not specify this parameter, an instance type that provides the fewest vCPUs and memory resources is automatically selected. This configuration is subject to resource availability of instance types. For example, the ecs.g6.large instance type is selected by default. If available ecs.g6.large resources are insufficient, the ecs.g6.xlarge instance type is selected.

SystemDiskSize Integer No 40

The size of the system disk of the intermediate instance. Unit: GiB. Valid values: 20 to 500.

Default value: 40.

InternetMaxBandwidthOut Integer No 0

The size of the outbound public bandwidth for the intermediate instance. Unit: Mbit/s. Valid values: 0 to 100.

Default value: 0.

DeleteInstanceOnFailure Boolean No true

Specifies whether to release the intermediate instance if the image cannot be created. Valid values:

  • true: releases the intermediate instance if the image cannot be created.
  • false: does not release the intermediate instance if the image cannot be created.

Default value: true.

Note If the intermediate instance cannot be started, the instance is released by default.
BuildContent String No FROM IMAGE:m-bp67acfmxazb4p****

The content of the image template. The content cannot be greater than 16 KB in size, and can contain up to 127 commands. For more information about the commands that are supported, see the "Description" section in this topic.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it 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.

Tag.N.Key String No TestKey

The key of tag N. Valid values of N: 1 to 20. The tag key cannot be an empty string. It can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

Tag.N.Value String No TestValue

The value of tag N. Valid values of N: 1 to 20. The tag value can be an empty string. It can be up to 128 characters in length. It cannot start with acs: or contain http:// or https://.

AddAccount.N Long No 1234567890

The ID of Alibaba Cloud account N to which to share the created image. Valid values of N: 1 to 20.

ToRegionId.N String No cn-hangzhou

The ID of region N to which to distribute the created image. Valid values of N: 1 to 20.

If you do not specify this parameter, the image is created only in the current region by default.

Response parameters

Parameter Type Example Description
ImagePipelineId String ip-2ze5tsl5bp6nf2b3****

The ID of the image template.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=CreateImagePipeline
&BaseImage=m-bp67acfmxazb4p****
&BaseImageType=IMAGE
&RegionId=cn-hangzhou
&Name=testImagePipeline
&BuildContent=FROM IMAGE:m-bp67acfmxazb4p****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateImagePipelineResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
    <ImagePipelineId>ip-2ze5tsl5bp6nf2b3****</ImagePipelineId>
</CreateImagePipelineResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "ImagePipelineId" : "ip-2ze5tsl5bp6nf2b3****"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidImage.NotFound %s The error message returned because the specified parameter is invalid. For more information, see the return value of the %s placeholder in the error message.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The error message returned because the specified ResourceGroupId parameter does not exist.

For a list of error codes, visit the API Error Center.