创建实例
描述
创建一台或多台主机实例。
要求
- 账号必须开启两步验证;
- 账号可用余额大于
100元;
请求路径
POST /v1/instances
请求参数
| 参数名称 | 参数类型 | 必填 | 描述 |
|---|---|---|---|
| cost | Object | 否 | 实例的付费信息 |
| cost.chargeType | string | 否 | 实例的付费方式,取值范围:PrePaid :包年包月PostPaid :按量付费 (默认值) |
| cost.periodUnit | string | 否 | 包年包月计费方式的时长单位,取值范围: Month:月 (默认值)Year:年 |
| cost.period | int | 否 | 购买资源的时长,当参数 chargeType 取值为 PrePaid 时才生效且为必选值,单位由 periodunit 指定。默认值为 1 |
| cost.autoRenew | object | 否 | 自动续费配置对象,当参数 chargeType 取值为 PrePaid 时才生效 |
| cost.autoRenew.enabled | boolean | 否 | 是否启用自动续费,取值范围:true:启用自动续费 false:不启用自动续费(默认值) |
| cost.autoRenew.period | int | 否 | 自动续费时长,默认值为 1,当 enabled 为 true 时生效 |
| cost.autoRenew.periodUnit | string | 否 | 自动续费时长单位,取值范围:Month:月(默认值)Year:年,当 enabled 为 true 时生效 |
| quantity | int | 否 | 指定创建实例的数量。取值范围:1~10,默认值:1 |
| instanceType | string | 是 | 实例类型 |
| imageID | string | 是 | 镜像 ID |
| systemDisk.diskType | string | 否 | 系统盘种类: local.ssd、cloud.ssd,默认为: local.ssd |
| systemDisk.size | int | 是 | 系统盘大小,单位为 GiB。取值范围:20~500 |
| dataDisks.diskType | string | 否 | 数据盘种类: cloud.ssd,默认为: cloud.ssd |
| dataDisks.size | int | 是 | 数据盘大小,单位为 GiB。取值范围:20~500 |
| dataDisks.deleteWithInstance | boolean | 否 | 数据盘是否随主机实例一同释放,默认值: false |
| internetMaxBandwidth | int | 否 | 峰值带宽大小,为 0 则表示不需要公网 IP |
| internetCost | Object | 否 | 网络计费信息,仅当 internetMaxBandwidth 大于 0 时有意义 |
| internetCost.chargeType | string | 否 | 网络付费方式,取值范围:Bandwidth:按带宽计费(默认值)PeakBandwidth:按峰值带宽计费Traffic:按流量计费 |
| userData | string | 否 | 实例自定义数据,必须采用 Base64 编码,且在进行 Base64 编码前自定义数据内容的大小不能超过 32 KB |
| hostnames | string[] | 否 | 创建多台实例时,为每台实例指定不同的主机名,长度为 2~60 个字符 |
| names | string[] | 否 | 实例名称,长度为 2~60 个字符 |
| description | string | 否 | 实例的描述,长度小于 100 个字符 |
| password | string | 否 | 实例的密码,8~30 个字符,至少包含大小写字母、数字和特殊符号中的三类字符,允许特殊字符:()`~!@#$%^&*-_+= |
| clientToken | string | 是 | 保证请求幂等性,从客户端生成一个参数值,确保不同请求间该参数值唯一,只支持 ASCII 字符,1~64 个字符 |
响应字段
| 字段名称 | 字段类型 | 描述 |
|---|---|---|
| instanceIDs | string array | 创建的实例 ID 列表 |
请求示例
POST /v1/instances HTTP/1.1
Host: <RegionID>-ecs.qiniuapi.com
Authorization: Qiniu <AccessToken>
Content-Type: application/json
{
"instanceType": "ecs.c1.large",
"imageID": "img-12345678",
"systemDisk": {
"diskType": "local.ssd",
"size": 40
},
"quantity": 1,
"cost": {
"chargeType": "PostPaid"
},
"internetMaxBandwidth": 20,
"userData": "IyEvYmluL2Jhc2gKZWNobyAnSGVsbG8gUWluaXUnID4+IC92YXIvbG9nL2Nsb3VkLmxvZw==",
"names": ["my-instance"],
"hostnames": ["my-instance"],
"clientToken": "create-instance-2024-01-01"
}
响应示例
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"instanceIDs": ["i-1234567890abcdef"]
}
文档反馈
(如有产品使用问题,请 提交工单)