EnableScalingGroup - 启用一个伸缩组

更新时间:
复制 MD 格式

启用一个伸缩组。

接口说明

  • 当伸缩组处于 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:EnableScalingGroupupdate
*ScalingGroup
acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}

请求参数

名称类型必填描述示例值
ScalingGroupIdstring

伸缩组的 ID。

asg-bp14wlu85wrpchm0****
ActiveScalingConfigurationIdstring

需要在伸缩组内启用的伸缩配置的 ID。

asc-bp1ffogfdauy0nu5****
LaunchTemplateIdstring

实例启动模板的 ID,用于指定伸缩组从实例启动模板获取启动配置信息。

lt-m5e3ofjr1zn1aw7****
LaunchTemplateVersionstring

实例启动模板的版本。取值范围:

  • 固定的模板版本号。
  • Default:始终使用模板默认版本。
  • Latest:始终使用模板最新版本。
Default
InstanceIdarray

启用伸缩组后需要加入伸缩组的 ECS 实例的 ID,N 的取值范围:1~20。

指定加入伸缩组的 ECS 实例需要满足以下条件:

  • 必须与伸缩组在同一个地域。

  • 必须处于 Running 状态。

  • 不能已加入到其他伸缩组中。

  • 付费方式为包年包月、按量付费或抢占式实例。

  • 如果伸缩组指定 VswitchID,则不支持 Classic 类型的 ECS 实例加入伸缩组,也不支持其他 VPC 的 ECS 实例加入伸缩组。

  • 如果伸缩组没有指定 VswitchID,则不支持 VPC 类型的 ECS 实例加入伸缩组。

string

启用伸缩组后需要加入伸缩组的 ECS 实例的 ID,N 的取值范围:1~20。

指定加入伸缩组的 ECS 实例需要满足以下条件:

  • 必须与伸缩组在同一个地域。

  • 必须处于 Running 状态。

  • 不能已加入到其他伸缩组中。

  • 付费方式为包年包月、按量付费或抢占式实例。

  • 如果伸缩组指定 VswitchID,则不支持 Classic 类型的 ECS 实例加入伸缩组,也不支持其他 VPC 的 ECS 实例加入伸缩组。

  • 如果伸缩组没有指定 VswitchID,则不支持 VPC 类型的 ECS 实例加入伸缩组。

i-283vv****
LoadBalancerWeightarray

加入伸缩组中 ECS 实例或 ECI 实例作为后端服务器的权重,N 的取值范围:1~20,该参数取值范围:1~100。

默认值:50。

integer

加入伸缩组的 ECS 实例或 ECI 实例作为后端服务器的权重,N 的取值范围:1~20,该参数取值范围:1~100。

默认值:50。

50
LaunchTemplateOverridearray<object>

实例启动模板的覆盖层信息。

object

实例启动模板的覆盖层信息。

InstanceTypestring

当您需要伸缩组按照实例规格容量进行伸缩时,请同时指定本参数和 LaunchTemplateOverride.N.WeightedCapacity。

本参数用于指定实例规格,会覆盖启动模板中的实例规格。您可以指定 N 个本参数,扩展启动模板支持 N 个实例规格。N 的取值范围:1~10。

说明 仅当 LaunchTemplateId 参数指定了启动模板时,本参数生效。

InstanceType 的取值范围:在售的 ECS 实例规格,请参见实例规格族

ecs.c5.xlarge
WeightedCapacityinteger

当您需要伸缩组按照实例规格容量进行伸缩时,在指定 LaunchTemplateOverride.N.InstanceType 后,再指定本参数。两个参数一一对应,N 需要保持一致。

本参数用于指定实例规格的权重,即实例规格的单台实例在伸缩组中表示的容量大小。权重越大,满足期望容量所需的本实例规格的实例数量越少。

由于每个实例规格的 vCPU 个数、内存大小等性能指标会有差异,您可以根据自身需求,给不同的实例规格配置不同的权重。

例如:

  • 当前容量:0。
  • 期望容量:6。
  • ecs.c5.xlarge 规格容量:4。

为满足期望容量,伸缩组将为用户扩容 2 台 ecs.c5.xlarge 实例。

说明 扩容时伸缩组的容量不得超过最大容量(MaxSize)与实例规格的最大权重之和。

WeightedCapacity 的取值范围:1~500。

4
RegionIdstring

伸缩组所属的地域 ID。

cn-qingdao

返回参数

名称类型描述示例值
object
RequestIdstring

请求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

示例

正常返回示例

JSON格式

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

错误码

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

变更历史

变更时间变更内容概要操作
2025-02-25OpenAPI 描述信息更新查看变更详情
HttpCode错误码错误信息描述
404InvalidScalingGroupId.NotFoundThe specified scaling group does not exist.指定的伸缩组在当前账号下不存在。
403Forbidden.UnauthorizedA required authorization for the specified action is not supplied.您并未向弹性伸缩完整授权 OpenAPI 接口。
400IncorrectScalingGroupStatusThe current status of the specified scaling group does not support this action.指定的伸缩组处于 Deleting 状态。
404InvalidScalingConfigurationId.NotFoundThe specified scaling configuration does not exist.指定的伸缩配置不存在指定的伸缩组中。
400InvalidScalingConfigurationId.InstanceTypeMismatchThe specified scaling configuration and existing active scaling configuration have different instance type.指定的伸缩配置的实例规格与当前生效的伸缩配置的实例规格不匹配。
400MissingActiveScalingConfigurationAn active scaling configuration for the specified scaling group is not supplied.伸缩组中未指定生效的伸缩配置。
404InvalidInstanceId.NotFoundInstance "XXX" does not exist.指定的 ECS 实例在当前账号下不存在。
400InvalidInstanceId. RegionMismatchInstance "XXX" and the specified scaling group are not in the same Region.指定的 ECS 实例与伸缩组所处的地域不匹配。
400InvalidInstanceId. InstanceTypeMismatchInstance "XXX" and existing active scaling configuration have different instance type.指定的 ECS 实例与伸缩配置的实例规格不匹配。
400IncorrectInstanceStatusThe current status of instance "XXX" does not support this action.指定的 ECS 实例未处于 Running 状态。
400InvalidInstanceId. NetworkTypeMismatchThe network type of instance "XXX" does not support this action.指定的 ECS 实例的网络类型与伸缩组的网络类型不匹配。
400InvalidInstanceId.VPCMismatchInstance "XXX" and the specified scaling group are not in the same VPC.指定的伸缩组与添加的 ECS 实例不在同一个 VPC 当中。
400InvalidInstanceId.InUseInstance "XXX" is already attached to another scaling group.指定的 ECS 实例已加入其它伸缩组。
400IncorrectLoadBalancerStatusThe current status of the specified load balancer does not support this action.指定的负载均衡实例未处于 active 状态。
400IncorrectLoadBalancerHealthCheckThe current health check type of specified load balancer does not support this action.指定的负载均衡实例未开启健康检查。
400InvalidLoadBalancerId.IncorrectInstanceNetworkTypeThe network type of the instance in specified Load Balancer does not support this action.指定的负载均衡实例含有的 ECS 实例的网络类型与伸缩组的网络类型不匹配。
400InvalidLoadBalancerId.VPCMismatchThe specified virtual switch and the instance in specified Load Balancer are not in the same VPC.指定的伸缩组的负载均衡实例含有的 ECS 实例与 VSwitchId 不在同一个 VPC 当中。
400IncorrectDBInstanceStatusThe current status of DB instance "XXX" does not support this action.指定的 RDS 实例未处于 Running 状态。
400IncorrectCapacity.MaxSizeTo attach the instances, the total capacity will be greater than the max size.加入的 ECS 实例数使得 Total Capacity 超过 MaxSize。
400LaunchTemplateVersionSet.NotFoundThe specific version of launch template is not exist.实例启动模板指定版本不存在。
400LaunchTemplateSet.NotFoundThe specified launch template set is not found.指定实例启动模板不存在。
400TemplateMissingParameter.ImageIdThe input parameter "ImageId" that is mandatory for processing this request is not supplied.实例启动模板指定版本缺少镜像信息。
400TemplateMissingParameter.InstanceTypesThe input parameter "InstanceTypes" that is mandatory for processing this request is not supplied.实例启动模板指定版本缺少实例规格信息。
400TemplateMissingParameter.SecurityGroupThe input parameter "SecurityGroup" that is mandatory for processing this request is not supplied.实例启动模板指定版本缺少安全组信息。
400TemplateVersion.NotNumberThe input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number.指定实例启动模板固定版本号为非数字。