CreateInstances
1. API Description
This API is used to create one or more virtual machine instances with a specified configuration.
Prerequisites
Query instance model: call
DescribeZoneInstanceConfigInfos
to check specifications.Query image: call
DescribeImages
to check information on image.
Note
After an instance is created successfully, it will start up automatically, and the instance status will become "
RUNNING
".If you create a subscription instance, the amount required will be pre-deducted. If the balance is insufficient, the request will fail. If you create a pay-as-you-go instance, please ensure your account balance is sufficient before calling this API.
Vouchers can be used for fee deduction in instance creation. See Vouchers for more details.
This API is an async API. An instance ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the instance will be
PENDING
orDEPLOYING
during the creation. You can useDescribeInstances
to query the status of the instance. If the status (instanceStatus
) changes fromPENDING
orDEPLOYING
toRunning
, it means that the instance has been created successfully; if no instance has been queried, it means the instance has been created failed. Any operations on the instances are not allowed while creating.A maximum of 100 instances can be created in one request.
2. Input Parameters
The following request parameter list only provides API request parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
zoneId | Yes | String | Zone ID to which the instances belong. |
instanceChargeType | Yes | String | |
instanceChargePrepaid | No | Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the | |
instanceType | Yes | String | Instance model ID.
To view specific values, you can call
|
imageId | Yes | String | Valid image ID.
To obtain valid image ID, you can call |
resourceGroupId | No | String | Resource group ID where the instances reside. If the value is empty, the instance will be added into the default resource group. |
instanceName | No | String | Instance name to be displayed. Default value: instance. This parameter can contain up to 64 characters. Only letters, numbers, - and periods (.) are supported. If you purchase multiple instances at the same time, you can specify a pattern string
For example, if you purchase 1 instance and the instance name body is Note:
|
instanceCount | No | Integer | The number of instances to be purchased. Value range: [1,100]. Default value: 1. |
password | No | String | Instance password. The parameter must be 8-16 characters, including:
You must and can only pass the value of either |
keyId | No | String | SSH key pair ID. Your SSH key pair contains several public keys that can be placed on your server. You can access your instance with the private key. SSH key pairs and passwords cannot to set at the same time. SSH key pairs are not supported for Windows operating system.
For example: |
internetChargeType | Yes | String | Public network pricing model. See InternetChargeType for details. |
internetMaxBandwidthOut | No | Integer | Public network bandwidth cap (Mbps). Default value: 1 Mbps. The parameter value differs with different instance models. See bandwidth configuration for details. |
trafficPackageSize | No | Float | Traffic package size (TB). The parameter is valid only when |
subnetId | Yes | String | Subnet ID. |
systemDisk | No | System disk configuration. If the value is empty, the system disk size is the minimum default value to store the operating system. | |
dataDisks | No | Array of DataDisk | Data disk configuration. If the value is empty, no data disk is attached by default. Only 10 data disk can be attached along with the instance for now. |
securityGroupId | No | String | Security group ID.
To obtain security group ID, you can call DescribeSecurityGroups , and find |
3. Output Parameters
Parameter Name | Type | Description |
---|---|---|
instanceIdSet | Array of String | List of instance IDs. The returned instance ID list does not mean the creation has been completed. The status of the instance will be |
orderNumber | String | Number of order. |
instances | Array of DiskWithInstance | Set of data disk IDs created along with the instances. If no data disk is specified, the value is empty. |
requestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
4. Code Example
Create a pay-as-you-go instance with the simplest parameters Assuming to create a pay-as-you-go instance in Seoul A with the model of 1c2g, 1 Mbps flat rate bandwidth billing method, random system-generated password, and no images installed.
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_PARAMETER_INSTANCE_NAME_EXCEED | Invalid instance name length. The specified instance name exceeds the maximum length. |
400 | INVALID_PARAMETER_INSTANCE_NAME_MALFORMED | Invalid instance name format. |
403 | OPERATION_FILED_INTERNET_CHARGE_TYPE_NOT_SUPPORT | Network billing method not supported in current zone. |
404 | INVALID_IMAGE_NOT_FOUND | Image not found. |
404 | INVALID_ZONE_NOT_FOUND | Zone does not exist. |
404 | INVALID_INSTANCE_TYPE_NOT_FOUND | Instance model not found. |
403 | INVALID_PARTITION_IMAGE_NOT_SET | Custom partition are only supported for specific operating system. |
403 | OPERATION_DENIED_INSTANCE_QUOTA_EXCEED | You are trying to create more instances than your remaining quota allows. |
400 | INVALID_BANDWIDTH_VALUE_EXCEED_MAXIMUM | Bandwidth exceeds the maximum limit. |
400 | INVALID_PARAMETER_VALUE_PASSWORD_MALFORMED | Invalid password. |
400 | RESOURCE_INSUFFICIENT_PRODUCT_SOLD_OUT | Resources not for sale. |
403 | OPERATION_DENIED_CHARGE_TYPE_NOT_SUPPORT | Pricing model not supported in current zone. |
400 | RESOURCES_SOLDOUT_INSTANCE_TYPE | Instance models sold out. |
400 | INVALID_DISK_SIZE_LESS_MINIMUM | Data disk size should be larger than the minimum limit. |
400 | INVALID_DISK_SIZE_EXCEED_MAXIMUM | Data disk size exceeds the maximum limit. |
403 | OPERATION_DENIED_SUBNET_ZONE_MISMATCH | Subnet the instance added in is not in the current zone. |
400 | INVALID_SYSTEM_DISK_SIZE | Invalid system disk size. The size should be multiples of 10 GB. |
400 | INVALID_SYSTEM_DISK_EXCEED_LIMIT | System disk size exceeds the maximum limit. |
400 | INVALID_INSTANCE_TYPE_ZONE_NO_SELL | Instance models sold out or not for sale in the current zone. |
400 | INVALID_DISK_ZONE_NO_SELL | Data disks sold out or not for sale in the current zone. You cannot create a data disk for now. |
403 | OPERATION_DENIED_INTERNET_CHARGE_TYPE_NOT_SUPPORT | Public network billing model not supported in current zone. |
400 | INVALID_PASSWORD_MALFORMED | Invalid password format. Please check the specified restrictions again. |
400 | INVALID_PARAMETER_BANDWIDTH_EXCEED | Public bandwidth exceeds the maximum limit. |
403 | OPERATION_DENIED_SUBNET_IP_INSUFFICIENT | Insufficient private IP addresses in the subnet. |
400 | INVALID_PARAMETER_TRAFFIC_PACKAGE_EXCEED | Size of data transfer package exceeds the maximum limit. |
400 | INVALID_PARAMETER_TRAFFIC_PACKAGE | Invalid data transfer package size. The size should be multiples of 0.1 TB or 1 TB. |
403 | INVALID_REGION_SECURITY_GROUP_NOT_SUPPORT | Security groups not supported in the zone. |
Last updated