启用一个伸缩组。
接口说明
-
当伸缩组处于 Inactive 状态,且伸缩组配置了组内实例的配置信息来源(伸缩配置、启动模板或者在创建伸缩组时指定 ECS 实例)时,才可以调用该接口来启用伸缩组。否则,会调用失败。
说明 一个伸缩组在同一时刻有且只有一个生效的实例配置信息来源。在调用接口时,您可以为伸缩组指定伸缩配置或启动模板。如果调用该接口前您已经为伸缩组配置了实例配置信息来源,在调用时再指定伸缩配置或启动模板会覆盖原有的配置信息。 -
当该接口指定了加入伸缩组的 ECS 实例(InstanceId.N),调用该接口后,弹性伸缩会判断在加入 ECS 实例后伸缩组的 ECS 实例数量(Total Capacity)是否在最小值(MinSize)和最大值(MaxSize)之间:
- 如果伸缩组的 Total Capacity 小于 MinSize,调用成功后,弹性伸缩服务会自动创建差额的按量付费的 ECS 实例。
例如:创建伸缩组时,指定 MinSize 为 5,在启用伸缩组的 InstanceId.N 参数中指定 2 台已有 ECS 实例,则弹性伸缩在加入 2 台已有 ECS 实例之后,再自动创建 3 台 ECS 实例。
- 如果伸缩组的 Total Capacity 大于 MaxSize,则调用失败。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:
- 对于必选的资源类型,用前面加 * 表示。
- 对于不支持资源级授权的操作,用
全部资源表示。
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
| 操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 |
|---|---|---|---|---|
| ess:EnableScalingGroup | update | *ScalingGroup acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId} |
| 无 |
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 |
|---|---|---|---|---|
| ScalingGroupId | string | 是 | 伸缩组的 ID。 | asg-bp14wlu85wrpchm0**** |
| ActiveScalingConfigurationId | string | 否 | 需要在伸缩组内启用的伸缩配置的 ID。 | asc-bp1ffogfdauy0nu5**** |
| LaunchTemplateId | string | 否 | 实例启动模板的 ID,用于指定伸缩组从实例启动模板获取启动配置信息。 | lt-m5e3ofjr1zn1aw7**** |
| LaunchTemplateVersion | string | 否 | 实例启动模板的版本。取值范围:
| Default |
| InstanceId | array | 否 | 启用伸缩组后需要加入伸缩组的 ECS 实例的 ID,N 的取值范围:1~20。 指定加入伸缩组的 ECS 实例需要满足以下条件:
| |
| string | 否 | 启用伸缩组后需要加入伸缩组的 ECS 实例的 ID,N 的取值范围:1~20。 指定加入伸缩组的 ECS 实例需要满足以下条件:
| i-283vv**** | |
| LoadBalancerWeight | array | 否 | 加入伸缩组中 ECS 实例或 ECI 实例作为后端服务器的权重,N 的取值范围:1~20,该参数取值范围:1~100。 默认值:50。 | |
| integer | 否 | 加入伸缩组的 ECS 实例或 ECI 实例作为后端服务器的权重,N 的取值范围:1~20,该参数取值范围:1~100。 默认值:50。 | 50 | |
| LaunchTemplateOverride | array<object> | 否 | 实例启动模板的覆盖层信息。 | |
| object | 否 | 实例启动模板的覆盖层信息。 | ||
| InstanceType | string | 否 | 当您需要伸缩组按照实例规格容量进行伸缩时,请同时指定本参数和 LaunchTemplateOverride.N.WeightedCapacity。 本参数用于指定实例规格,会覆盖启动模板中的实例规格。您可以指定 N 个本参数,扩展启动模板支持 N 个实例规格。N 的取值范围:1~10。 说明
仅当 LaunchTemplateId 参数指定了启动模板时,本参数生效。
InstanceType 的取值范围:在售的 ECS 实例规格,请参见实例规格族。 | ecs.c5.xlarge |
| WeightedCapacity | integer | 否 | 当您需要伸缩组按照实例规格容量进行伸缩时,在指定 LaunchTemplateOverride.N.InstanceType 后,再指定本参数。两个参数一一对应,N 需要保持一致。 本参数用于指定实例规格的权重,即实例规格的单台实例在伸缩组中表示的容量大小。权重越大,满足期望容量所需的本实例规格的实例数量越少。 由于每个实例规格的 vCPU 个数、内存大小等性能指标会有差异,您可以根据自身需求,给不同的实例规格配置不同的权重。 例如:
为满足期望容量,伸缩组将为用户扩容 2 台 ecs.c5.xlarge 实例。 说明
扩容时伸缩组的容量不得超过最大容量(MaxSize)与实例规格的最大权重之和。
WeightedCapacity 的取值范围:1~500。 | 4 |
| RegionId | string | 否 | 伸缩组所属的地域 ID。 | cn-qingdao |
返回参数
示例
正常返回示例
JSON格式
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}错误码
访问错误中心查看更多错误码。
变更历史
| 变更时间 | 变更内容概要 | 操作 |
|---|---|---|
| 2025-02-25 | OpenAPI 描述信息更新 | 查看变更详情 |
| HttpCode | 错误码 | 错误信息 | 描述 |
|---|---|---|---|
| 404 | InvalidScalingGroupId.NotFound | The specified scaling group does not exist. | 指定的伸缩组在当前账号下不存在。 |
| 403 | Forbidden.Unauthorized | A required authorization for the specified action is not supplied. | 您并未向弹性伸缩完整授权 OpenAPI 接口。 |
| 400 | IncorrectScalingGroupStatus | The current status of the specified scaling group does not support this action. | 指定的伸缩组处于 Deleting 状态。 |
| 404 | InvalidScalingConfigurationId.NotFound | The specified scaling configuration does not exist. | 指定的伸缩配置不存在指定的伸缩组中。 |
| 400 | InvalidScalingConfigurationId.InstanceTypeMismatch | The specified scaling configuration and existing active scaling configuration have different instance type. | 指定的伸缩配置的实例规格与当前生效的伸缩配置的实例规格不匹配。 |
| 400 | MissingActiveScalingConfiguration | An active scaling configuration for the specified scaling group is not supplied. | 伸缩组中未指定生效的伸缩配置。 |
| 404 | InvalidInstanceId.NotFound | Instance "XXX" does not exist. | 指定的 ECS 实例在当前账号下不存在。 |
| 400 | InvalidInstanceId. RegionMismatch | Instance "XXX" and the specified scaling group are not in the same Region. | 指定的 ECS 实例与伸缩组所处的地域不匹配。 |
| 400 | InvalidInstanceId. InstanceTypeMismatch | Instance "XXX" and existing active scaling configuration have different instance type. | 指定的 ECS 实例与伸缩配置的实例规格不匹配。 |
| 400 | IncorrectInstanceStatus | The current status of instance "XXX" does not support this action. | 指定的 ECS 实例未处于 Running 状态。 |
| 400 | InvalidInstanceId. NetworkTypeMismatch | The network type of instance "XXX" does not support this action. | 指定的 ECS 实例的网络类型与伸缩组的网络类型不匹配。 |
| 400 | InvalidInstanceId.VPCMismatch | Instance "XXX" and the specified scaling group are not in the same VPC. | 指定的伸缩组与添加的 ECS 实例不在同一个 VPC 当中。 |
| 400 | InvalidInstanceId.InUse | Instance "XXX" is already attached to another scaling group. | 指定的 ECS 实例已加入其它伸缩组。 |
| 400 | IncorrectLoadBalancerStatus | The current status of the specified load balancer does not support this action. | 指定的负载均衡实例未处于 active 状态。 |
| 400 | IncorrectLoadBalancerHealthCheck | The current health check type of specified load balancer does not support this action. | 指定的负载均衡实例未开启健康检查。 |
| 400 | InvalidLoadBalancerId.IncorrectInstanceNetworkType | The network type of the instance in specified Load Balancer does not support this action. | 指定的负载均衡实例含有的 ECS 实例的网络类型与伸缩组的网络类型不匹配。 |
| 400 | InvalidLoadBalancerId.VPCMismatch | The specified virtual switch and the instance in specified Load Balancer are not in the same VPC. | 指定的伸缩组的负载均衡实例含有的 ECS 实例与 VSwitchId 不在同一个 VPC 当中。 |
| 400 | IncorrectDBInstanceStatus | The current status of DB instance "XXX" does not support this action. | 指定的 RDS 实例未处于 Running 状态。 |
| 400 | IncorrectCapacity.MaxSize | To attach the instances, the total capacity will be greater than the max size. | 加入的 ECS 实例数使得 Total Capacity 超过 MaxSize。 |
| 400 | LaunchTemplateVersionSet.NotFound | The specific version of launch template is not exist. | 实例启动模板指定版本不存在。 |
| 400 | LaunchTemplateSet.NotFound | The specified launch template set is not found. | 指定实例启动模板不存在。 |
| 400 | TemplateMissingParameter.ImageId | The input parameter "ImageId" that is mandatory for processing this request is not supplied. | 实例启动模板指定版本缺少镜像信息。 |
| 400 | TemplateMissingParameter.InstanceTypes | The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied. | 实例启动模板指定版本缺少实例规格信息。 |
| 400 | TemplateMissingParameter.SecurityGroup | The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied. | 实例启动模板指定版本缺少安全组信息。 |
| 400 | TemplateVersion.NotNumber | The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number. | 指定实例启动模板固定版本号为非数字。 |
