调用CreateInstances创建一台或多台轻量应用服务器。

使用说明

  • 在调用该接口前,建议您了解轻量应用服务器的计费信息。更多信息,请参见计费项
  • 同一个阿里云账号内,最多同时存在20台轻量应用服务器。
  • 调用该接口创建服务器时,您需要确保您的阿里云账户余额充足,否则会创建失败。

QPS限制

本接口的单用户QPS限制为10次/分钟。超过限制,API调用会被限流,这可能会影响您的业务,请合理调用。更多信息,请参见QPS限制

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateInstances

系统规定参数。取值:CreateInstances

RegionId String cn-hangzhou

地域ID。您可以调用ListRegions查询可用地域。

ImageId String e2c9c365024a44369c9b955a998a****

镜像ID。您可以调用ListImages查询指定地域下可用的镜像ID。

PlanId String swas.s1.c1m1s40b3t05

套餐ID。您可以调用ListPlans查询指定地域下的全部套餐信息。

Period Integer 1

购买资源的时长。单位:月。取值范围:{"1", "3", "6", "12", "24", "36"}

AutoRenew Boolean false

是否开启到期自动续费。取值范围:

  • true:开启
  • false:不开启

默认值:false

AutoRenewPeriod Integer 1

自动续费的时长,仅当AutoRenew=true时该参数必填。单位:月。取值范围:{"1", "3", "6", "12", "24", "36"}

DataDiskSize Long 20

挂载的数据盘容量大小。单位:GB。取值范围:0~16380,取值必须是20的整数倍。

  • 取值为0时,表示不挂载数据盘。
  • 如果您选择的套餐使用的是ESSD云盘(性能级别PL0),则挂载的数据盘容量最小值为40 GB。
  • 如果您选择的套餐使用的是SSD云盘,则挂载的数据盘容量最小值为20 GB。

默认值:0

Amount Integer 1

创建轻量应用服务器的数量。取值范围:1~20

默认值:1

ChargeType String PrePaid

计费方式。取值:PrePaid,目前仅支持包年包月计费方式。

默认值:PrePaid

ClientToken String 123e4567-e89b-12d3-a456-426655440000

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符,且不能超过64个字符。更多信息,请参见如何保证幂等性

返回数据

名称 类型 示例值 描述
RequestId String 30637AD6-D977-4833-A54C-CC89483E1FEE

请求ID。

InstanceIds Array of String 3a658ca270df4df39f22e289b338****

轻量应用服务器的实例ID。

示例

请求示例

http(s)://swas.cn-hangzhou.aliyuncs.com/?Action=CreateInstances
&RegionId=cn-hangzhou	
&ImageId=e2c9c365024a44369c9b955a998a****
&PlanId=swas.s1.c1m1s40b3t05
&Period=1
&AutoRenew=false
&AutoRenewPeriod=1
&DataDiskSize=20
&Amount=1
&ChargeType=PrePaid
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&公共请求参数

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateInstancesResponse>
    <RequestId>30637AD6-D977-4833-A54C-CC89483E1FEE</RequestId>
    <InstanceIds>3a658ca270df4df39f22e289b338****</InstanceIds>
</CreateInstancesResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "30637AD6-D977-4833-A54C-CC89483E1FEE",
  "InstanceIds" : [ "3a658ca270df4df39f22e289b338****" ]
}

错误码

HttpCode 错误码 错误信息 描述
400 NotEnoughStock The stock is insufficient. 库存不足。
400 PlatformNotMatch The platform of specified ImageId and PlanId does not match. 指定的套餐和镜像不匹配。
400 InvalidPeriod.ValueNotSupported The specified parameter Period is invalid. 指定的时长不合法。
400 InvalidDataDiskSize.ValueNotSupported The specified parameter DataDiskSize is invalid. 指定的数据盘大小不合法。
400 InvalidAmount.ValueNotSupported The specified parameter Amount is invalid. 指定的实例数不合法。
400 InvalidChargeType.ValueNotSupported The specified parameter ChargeType is invalid. 指定的实例计费方式不合法。
400 InvalidAutoRenewPeriod.ValueNotSupported The specified parameter AutoRenewPeriod is invalid. 指定的续费时长不合法。
400 InvalidPlanIdSize.ValueNotSupported The system disk size in the specified planId does not support the image. 指定的套餐包含的系统盘大小不支持当前镜像。
400 InvalidPlanMemorySize.ValueNotSupported The memory size in the specified planId does not support the image. 指定的套餐内存大小不支持当前镜像。
403 PaymentFailed Payment failed. Please check your account balance. 支付失败,请检查您的账户余额是否不足。
403 InvalidInstance.UnPaidOrder The specified Instance has an unpaid order. 您有未支付订单,请支付该类订单后再重新下单。
403 InvalidParam The specified parameter value is invalid. 参数非法。
404 InvalidImageId.NotFound The specified ImageId does not exist. 指定的镜像不存在,请您检查镜像ID是否正确。
404 InvalidPlanId.NotFound The specified PlanId does not exist. 指定的套餐不存在,请您检查套餐ID是否正确。
500 InternalError An error occurred while processing your request. 内部错误,请重试。如果多次尝试失败,请提交工单。
500 NotEnoughUpgradeStock The upgrade stock is insufficient. 升级库存不足。

访问错误中心查看更多错误码。