Creates an instance.
Operation description
- You can call this operation up to 10 times per second per account.
- We recommend that you increase the request time because instance creation is an asynchronous operation. If the return code of the API operation is 0, it indicates that the request is successful, but does not indicate that the instance is created. If the request is successful, an instance ID is returned. You can check whether the instance is created based on the instance ID.
- InvalidUserData.NotInWhiteList operation restriction: You can create an instance only if you are in the whitelist in which members have the purchase permissions. Otherwise, an error is returned.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ens:CreateInstance | create | *Instance acs:ens:*:{#accountId}:instance/* |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
InstanceType | string | Yes | 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 contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include: | yourPassword:1 |
Period | string | Yes | The subscription period of the instance. Valid values: 1 to 9 and 12. Unit: months. | 12 |
ImageId | string | No | The ID of the image file that you select when creating the instance. | yourImage ID |
SystemDisk.Size | string | No | The size of the system disk. Unit: GiB. Valid values: 20 and 40. The value cannot be smaller than the size of the image and must be a multiple of 10 GiB. | 40 |
Quantity | string | Yes | The number of instances. | 1 |
DataDisk.1.Size | string | No | The capacity of the first data disk. Unit: GiB. The capacity is at least 20 GiB and is a multiple of 10 GiB. | 50 |
InternetChargeType | string | No | This parameter is required if you create the instance for the first time. The existing billing method is used by default if you have created an instance. Valid values:
| 95BandwidthByMonth |
AutoRenewPeriod | string | No | The auto-renewal period for the instance. This parameter is required when the AutoRenew parameter is set to True. Valid values: 1 to 12. Unit: months. | 12 |
AutoRenew | string | No | Specifies whether to enable the auto-renewal feature. Valid values: True and False. Default value: False. | True |
IpType | string | No | The type of the IP address. Valid values:
| ipv4 |
KeyPairName | string | No | The name of the key pair. You can specify only one name. | TestKeyPairName |
UserData | string | No | Custom data. The data starts with You can specify custom data. The data is encoded in Base64. The system does not encrypt your custom data when API requests are initiated. We recommend that you do not pass in confidential information such as passwords and private keys in plaintext. If you want to provide sensitive data such as passwords and private keys, encrypt the data and then encode it in Base64. The data is decrypted on the instance in the way it is encrypted. For more information, see User data formats. | #!/bin/sh echo "Hello World. The time is now $(date -R)!" | tee /home/output.txt |
VSwitchId | string | No | The ID of the vSwitch. | YourVSwitchId |
PrivateIpAddress | string | No | The internal IP address. If this parameter is specified, you must specify the vSwitch ID. The vSwitch must be created first. Otherwise, an error is returned. | 10.10.10.10 |
PaymentType | string | No | The billing method of the instance. Set the value to Subscription. | Subscription |
InstanceName | string | No | The name of the instance. The name must conform to the following naming conventions:
If you do not specify this parameter, the instance ID is used as the instance name by default. | test:Instance_Name.1-2 |
HostName | string | No | The hostname of the Elastic Compute Service (ECS) instance. General naming rules: The hostname cannot start or end with a period (.) or hyphen (-). It cannot contain consecutive periods (.) or hyphens (-). Naming rules for specific instances:
| test-HostName |
UniqueSuffix | boolean | No | Specifies whether to automatically append sequential suffixes to the hostnames specified by the HostName parameter and instance names specified by the InstanceName parameter. The sequential suffixes range from 001 to 999. Examples: LocalHost001 and LocalHost002, and 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 parameters
Examples
Sample success responses
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 | StockNotEnough | The specified configuration is unavailable. Reconfigure and try again. | - |
400 | InvalidParameter.%s | The specified field %s invalid. Please check it again. | - |
400 | InvalidParameter | The errorMessage is %s. Please check it again. | - |
400 | StockNotEnough | The specified EnsRegionId is unavailable. Reconfigure and try again. | - |
400 | StockNotEnough | The specified InstanceSpec is unavailable. Reconfigure and try 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 | StockNotEnough | The specified node has insufficient resource. | - |
400 | InvalidParameter.Image | The specified image does not support. | - |
400 | StockNotEnough | You have reached the purchase default limit. | - |
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 | MissingParameter | The input parameter %s that is mandatory for processing this request is not supplied. | - |
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. | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-10-12 | The Error code has changed | View Change Details |
2023-03-03 | The Error code has changed | View Change Details |