CreateImage

1. API Description

This API is used to create a custom image from an instance.

Note

  • A custom image will be created in the same availability zone as the selected instance.

  • The instance must be in the STOPPED state.

  • GPU instances are currently not supported for custom image creation.

  • If the quota limit is exceeded, please contact us to request an increase.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

instanceId

Yes

String

Instance ID from which you create the image.

imageName

Yes

String

Image name. This parameter must start with a number or a letter, containing 2 to 63 characters. Only letters, numbers, -/_ and periods (.) are supported.

resourceGroupId

No

String

Resource group ID where the image reside.

If the value is empty, the image will be added into the default resource group.

tags

No

Bound tags when creating the image.

Tag keys must be unique.

3. Output Parameters

Parameter Name
Type
Description

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

imageId

String

Image ID.

imageName

String

Image name.

4. Code Example

Create a custom image from an instance.

POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateImage
<Common Request Params>

Request:
{
  "instanceId": "<instance id>",
  "imageName": "imageXXX"
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "imageId": "imageIdX",
    "imageName": "imageNameX"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.​

HTTP Status Code
Error Code
Description

400

INVALID_IMAGE_QUOTA_EXCEED

Quota limit of custom image is exceeded.

404

INVALID_INSTANCE_NOT_FOUND

Instance does not exist.

400

OPERATION_DENIED_GPU_INSTANCE_NOT_SUPPORT

GPU instances are not supported for custom image creation.

400

OPERATION_DENIED_INSTANCE_IN_OPERATION

Instance is performing another operation.

400

OPERATION_DENIED_INSTANCE_STATUS_NOT_SUPPORT

Instance state does not allow this operation.

Last updated