Creates a subscription instance. This operation can be replaced by RunInstances. No new features will be added to CreateInstance.
Operation description
Per-user call frequency: 10 calls per second.
Because instance creation is an asynchronous operation, increase the request timeout as needed. When the API returns Code=0, this only indicates that the request was successful, not that the instance was created successfully. An instance ID is returned upon a successful request. You can then query the instance by its ID to check whether the instance is created.
InvalidUserData.NotInWhiteList restriction: Only accounts that are added to the relevant whitelist with purchase permissions can create instances. Otherwise, an error is returned.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ens:CreateInstance |
create |
*Instance
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceType |
string |
Yes |
The instance type. For details about instance types, see Limits. |
ens.se1.tiny |
| EnsRegionId |
string |
Yes |
The region ID. |
cn-hangzhou |
| Password |
string |
No |
The password of the instance. The password must be 8 to 30 characters in length and must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported: |
yourPassword:1 |
| Period |
string |
Yes |
The subscription duration. Valid values: 1 to 9 and 12. Unit: months. |
12 |
| ImageId |
string |
No |
The ID of the image that is used to start the instance. |
yourImage ID |
| SystemDisk.Size |
string |
No |
The size of the system cloud disk. Unit: GiB. The value must be a multiple of 10 and cannot be smaller than the image size. For the valid range, refer to the SystemDiskMinSize and SystemDiskMaxSize values returned by DescribeAvailableResourceInfo. 20 GiB and 40 GiB are common configurations and do not indicate that only these two values are supported. |
40 |
| Quantity |
string |
Yes |
The number of instances. |
1 |
| DataDisk.1.Size |
string |
No |
The size of the first data cloud disk. Unit: GiB. The size must be at least 20 GiB and a multiple of 10. |
50 |
| InternetChargeType |
string |
No |
This parameter is required when you create an instance for the first time. If you already have instance resources, the existing billing method is used by default. Valid values:
|
95BandwidthByMonth |
| AutoRenewPeriod |
string |
No |
The auto-renewal period. This parameter is required when AutoRenew is set to True. Valid values: 1 to 12. Unit: months. |
12 |
| AutoRenew |
string |
No |
Specifies whether to enable auto-renewal. Valid values: True | False (default). |
True |
| IpType |
string |
No |
The IP type. Valid values:
Valid values:
|
ipv4 |
| KeyPairName |
string |
No |
The name of the key pair. Only a single name is supported. |
TestKeyPairName |
| UserData |
string |
No |
The custom data. The data must start with You can pass in custom data that is Base64-encoded. When you call the API to initiate a request, the custom data you specify is not encrypted. Do not pass in confidential information such as passwords and private keys in plaintext. If you need to pass in passwords or private keys, encrypt the content first and then Base64-encode it before passing it in. Decrypt the content in the same way inside the instance. For more information, see Data format. |
#!/bin/sh echo "Hello World. The time is now $(date -R)!" | tee /home/output.txt |
| VSwitchId |
string |
No |
The vSwitch ID. |
YourVSwitchId |
| PrivateIpAddress |
string |
No |
The private IP address. If you specify a private IP address, you must also specify the VSwitchId parameter. The vSwitch must be created in advance. Otherwise, an error is returned. |
10.10.10.10 |
| PaymentType |
string |
No |
The payment method. Currently, this is a fixed value of Subscription (subscription instance). Modification is not supported. Valid values:
|
Subscription |
| InstanceName |
string |
No |
The name of the instance. Naming conventions:
If this parameter is not specified, the default value is the InstanceId of the instance. |
test:Instance_Name.1-2 |
| HostName |
string |
No |
The hostname of the instance. General naming conventions: Periods (.) and hyphens (-) cannot be used as the first or last character and cannot be used consecutively. Specific naming conventions:
|
test-HostName |
| UniqueSuffix |
boolean |
No |
Specifies whether to add sequential suffixes to HostName and InstanceName. The sequential suffixes start from 001 and cannot exceed 999. Example: LocalHost001, LocalHost002, MyInstance001, and MyInstance002. Default value: false. |
false |
| PublicIpIdentification |
boolean |
No |
Specifies whether a public IP address can be assigned to the specified instance. Valid values:
|
true |
| PasswordInherit |
boolean |
No |
Specifies whether to use the preset password of the image. Valid values:
|
false |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
4A431388-2D4B-46F4-A96B-D4E6BD0688C1 |
| InstanceIds |
object |
||
| InstanceId |
array |
The list of instance IDs. |
|
|
string |
The list of instance IDs. |
[i-7ecpqvkicnchxccozrp****,i-6ecpqvkicnchxccozrp****] |
|
| Code |
integer |
The return code. A value of 0 indicates success. Note
If you call this API operation by using an SDK, the return type is Integer. If you call this API operation by using a common method or HTTP, the return type is String. |
0 |
Examples
Success response
JSON format
{
"RequestId": "4A431388-2D4B-46F4-A96B-D4E6BD0688C1",
"InstanceIds": {
"InstanceId": [
"[i-7ecpqvkicnchxccozrp****,i-6ecpqvkicnchxccozrp****]"
]
},
"Code": 0
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | StockNotEnough | The specified instance type has insufficient resource. | |
| 400 | InvalidUserData.NotInWhiteList | The specified user is not authroized to perform this operation. | |
| 400 | MissingParameter | The input parameter that is mandatory for processing this request is not supplied. | |
| 400 | InstanceIdNotFound | The input parameter instancdId that is not found. | The specified instance ID does not exist. |
| 400 | NoPermission | Permission denied. | |
| 400 | CallInterface | Call Interface Happen Error. | An error occurred when you call the operation. |
| 400 | InvalidParameter | The input parameter is Invalid. | |
| 400 | InvalidParameter.%s | The specified field %s invalid. Please check it again. | |
| 400 | InvalidDiskSize.ValueNotSupported | The specified disk capacity is invalid. Specify another capacity and try again. | |
| 400 | InvalidParameter.Bandwidth | The specified parameter InternetChargeType is not valid. | |
| 400 | InvalidParameter.Image | The specified image does not support. | |
| 400 | InvalidParameter.InstanceType | The specified parameter InstanceType is not valid. | |
| 400 | InvalidAccountStatus.NotEnoughBalance | Your account does not have enough balance. | |
| 400 | unsupported_Ipv6Feature | This ensregion does not support creating instance of the IPv6 type. Select another type. | |
| 400 | Forbidden.CreateInstance | The user is not in the Goods whitelist of creating instance interface. | |
| 400 | ENS_OperationUnsupported_KeyPairName | The KeyPairNameis not available or image not support ssh key. | |
| 400 | ENS_DependencyViolation_WindowsInstance | The instance creating is window, only user password to login. | |
| 400 | ENS_PASSWORDORKEYPAIRNAME_MODULE_NOT_CHOOSEN | The required module pwd or keyPairName is not inputed | |
| 400 | InvalidPrivateIpAddress | Specified private IP address is not in the CIDR block of virtual switch. | |
| 400 | InvalidVSwitchId.NotFound | Specified virtual switch does not exist. | The specified virtual switch ID does not exist. |
| 400 | InvalidPrivateIpAddress.Duplicated | Specified private IP address is duplicated. | |
| 400 | InvalidPasswordParam.Mismatch | The input password should be null when passwordInherit is true. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.