全部产品
Search
文档中心

资源编排:ALIYUN::ESS::ScalingConfiguration

更新时间:Nov 15, 2023

ALIYUN::ESS::ScalingConfiguration类型用于为伸缩组创建伸缩配置。

语法

{
  "Type": "ALIYUN::ESS::ScalingConfiguration",
  "Properties": {
    "PasswordInherit": Boolean,
    "DiskMappings": List,
    "RamRoleName": String,
    "IoOptimized": String,
    "InternetChargeType": String,
    "KeyPairName": String,
    "InstanceId": String,
    "InstanceTypes": List,
    "ImageId": String,
    "ResourceGroupId": String,
    "SpotStrategy": String,
    "InstanceType": String,
    "SystemDiskCategory": String,
    "SystemDiskSize": Integer,
    "SystemDiskAutoSnapshotPolicyId": String,
    "SystemDiskPerformanceLevel": String,
    "InternetMaxBandwidthOut": Integer,
    "InstanceName": String,
    "InternetMaxBandwidthIn": Integer,
    "ScalingConfigurationName": String,
    "UserData": String,
    "DeploymentSetId": String,
    "SecurityGroupId": String,
    "SpotPriceLimit": Number,
    "HpcClusterId": String,
    "ScalingGroupId": String,
    "SpotPriceLimitForInstanceType": Map,
    "TagList": List,
    "Ipv6AddressCount": Integer,
    "LoadBalancerWeight": Integer,
    "CreditSpecification": String,
    "ImageFamily": String,
    "HostName": String,
    "Password": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ResourceGroupId

String

实例所在的资源组ID。

DeploymentSetId

String

部署集ID。

HpcClusterId

String

实例所属的EHPC集群ID。

ScalingGroupId

String

伸缩配置所属的伸缩组ID。

DiskMappings

List

需要挂载的磁盘。

最多支持16块磁盘。

更多信息,请参见DiskMappings属性

InternetChargeType

String

公网访问带宽计费方式。

取值:

  • PayByBandwidth:按固定带宽计费。

  • PayByTraffic(默认值):按流量计费。

InternetMaxBandwidthIn

Integer

公网最大入网带宽。

单位:Mbps。

取值范围:1~200。

如果您没有指定该参数,则入带宽将自动被设置为200 Mbps。实例的入数据流量免费,该参数在任何情况下都不涉及计费。

InternetMaxBandwidthOut

Integer

公网最大出网带宽。

取值范围:

  • 按固定带宽计费:0~100。默认值:0。

  • 按流量计费:0~100。此时,该参数为必选参数。

单位:Mbps。

InstanceId

String

伸缩配置的实例ID。

SystemDiskCategory

String

系统盘类型。

取值:

  • cloud:普通云盘。

  • cloud_efficiency:高效云盘。

  • cloud_ssd:SSD云盘。

  • ephemeral_ssd:本地SSD盘。

  • cloud_essd:ESSD云盘。

当InstanceType为I系列的实例规格且实例属于非I/O优化实例时,默认值为cloud,否则,默认值为cloud_efficiency。

ImageId

String

实例的镜像ID,包括公共镜像、自定义镜像和云市场镜像。

更多信息,请参见公共镜像概述

InstanceType

String

实例规格。

更多信息,请参见实例规格族

SecurityGroupId

String

实例所属的安全组。

IoOptimized

String

是否创建I/O优化实例。

取值:

  • none(默认值):非I/O优化。

  • optimized:I/O优化。

ScalingConfigurationName

String

伸缩配置的名称。

长度为2~64个字符,以数字、英文字母或汉字开头,可包含数字、英文字母、汉字、下划线(_)、短划线(-)和半角句号(.)。

在同一地域下同一伸缩组内伸缩配置名称唯一。

如果您没有指定本参数,则默认使用伸缩配置的ID。

KeyPairName

String

实例绑定的密钥对名称。

  • 如果实例类型为Windows实例,则此参数将被忽略,默认值为空。

  • 如果实例类型为Linux实例,则密码登录方式会被初始化成禁止。

RamRoleName

String

实例RAM角色名称。

您可以使用RAM API ListRoles查询实例RAM角色名称。更多信息,请参见CreateRole - 创建角色ListRoles - 获取角色列表

SystemDiskSize

Integer

系统盘大小。

取值范围:20~500。

默认值:40。

单位:GiB。

如果使用自定义镜像创建系统盘,则系统盘大小必须大于等于自定义镜像大小。

SystemDiskPerformanceLevel

String

创建ESSD云盘作为系统盘使用时,设置云盘的性能等级。

取值:

  • PL1(默认值):单盘最高随机读写IOPS为5万。

  • PL2:单盘最高随机读写IOPS为10万。

  • PL3:单盘最高随机读写IOPS为100万。

有关如何选择ESSD性能等级,请参见ESSD云盘

UserData

String

创建实例时传递的用户数据。

内容需要限制在16KB以内,无需Base64转码,特殊字符需要使用反斜线(\)转义。

InstanceTypes

List

多实例规格参数。

如果指定了InstanceTypes,则InstanceType无效。

一个伸缩配置内最多可以设置10种实例规格,优先级按列表元素的顺序依次降低。当无法根据优先级较高的实例规格创建出实例时,弹性伸缩服务会自动选择下一优先级的实例规格来创建实例。

PasswordInherit

Boolean

是否使用镜像预设的密码。

如果使用镜像预设的密码,您需要确保所用镜像已经预设了密码。

TagList

List

实例标签。

标签以键值对方式传入,最多可以使用5组标签,格式为{"key1": "value1", "key2": "value2", ... "key5": "value5"}

更多信息,请参见TagList属性

Ipv6AddressCount

Integer

为弹性网卡指定随机生成的IPv6地址数量。

LoadBalancerWeight

Integer

ECS实例作为负载均衡后端服务器时的权重。

取值范围:1~100。

默认值:50。

CreditSpecification

String

突发性能实例的运行模式。

取值:

  • Unlimited(默认值):无性能约束模式。

  • Standard:标准模式。

关于实例性能的更多信息,请参见性能模式

ImageFamily

String

镜像族系名称。

通过设置该参数来获取当前镜像族系内最新可用镜像,用于创建实例。如果已经设置了参数ImageId,则不能设置该参数。

SpotStrategy

String

后付费实例的抢占策略。

取值:

  • NoSpot(默认值):正常按量付费实例。

  • SpotWithPriceLimit:设置上限价格的抢占式实例。

  • SpotAsPriceGo:系统自动出价,跟随当前市场实际价格。

InstanceName

String

基于当前伸缩配置创建的实例的名称。

SpotPriceLimit

Number

实例每小时的最高价格。

支持最多3位小数。

当SpotStrategy取值为SpotWithPriceLimit时该参数生效,且取值会被SpotPriceLimitForInstanceType的取值所覆盖。

SpotPriceLimitForInstanceType

Map

抢占式实例的实例规格和对应的出价。

格式:{“<instance_type_1>": <price_limit_1>, ..., {“<instance_type_10>": <price_limit_10>}

当SpotStrategy取值为SpotWithPriceLimit时该参数生效。

最多可设置10组实例和价格。

SystemDiskAutoSnapshotPolicyId

String

系统盘使用的自动快照策略ID。

HostName

String

云服务器的主机名。

半角句号(.)或短划线(-)不能作为首尾字符,不能连续使用半角句号(.)或短划线(-)。

不同类型实例的命名要求如下:

  • Windows实例:主机名长度为2~15,可以包含大小写字母、数字和短划线(-)。不能包含半角句号(.),不能全是数字。

  • 其他类型实例(Linux等):主机名长度为2~64,可以包含多个半角句号(.)。两个半角句号(.)之间为一段,每段可以包含大小写字母、数字和短划线(-)。

Password

String

ECS实例的密码。

长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号中的三类字符。特殊符号可以是:

()` ~!@#$%^&*-_+=\|{}[]:;'<>,.?/

Windows实例不能以斜线号(/)为密码首字符。

说明

如果传入Password参数,建议您使用HTTPS协议发送请求,避免密码泄露。

DiskMappings语法

"DiskMappings": [
  {
    "Category": String,
    "DiskName": String,
    "Description": String,
    "AutoSnapshotPolicyId": String,
    "PerformanceLevel": String,
    "Encrypted": String,
    "KMSKeyId": String,
    "Device": String,
    "SnapshotId": String,
    "Size": String
  }
]

DiskMappings属性

属性名称

类型

必须

允许更新

描述

约束

Size

String

数据盘磁盘大小。

取值:

  • cloud:5~2000。

  • cloud_efficiency:20~32,768。

  • cloud_ssd:20~32,768。

  • cloud_essd:20~32,768。

  • ephemeral_ssd:5~800。

单位:GB。

指定该参数后,磁盘大小必须大于等于快照大小(快照通过SnapshotId指定)。

Category

String

数据盘类型。

取值:

  • cloud:普通云盘。

  • cloud_efficiency(默认值):高效云盘。

  • cloud_ssd:SSD云盘。

  • ephemeral_ssd:本地SSD盘。

  • cloud_essd:ESSD云盘。

对于I/O优化实例,默认值为cloud_efficiency;对于非I/O优化实例,默认值为cloud。

DiskName

String

数据盘名称。

长度为2~128个字符。

必须以英文字母或汉字开头,不能以http://https:// 开头。

可以包含数字、英文字母、汉字、半角冒号(:)、下划线(_)和短划线(-)。

PerformanceLevel

String

创建ESSD云盘作为数据盘使用时,设置云盘的性能等级。

取值:

  • PL1(默认值):单盘最高随机读写IOPS为5万。

  • PL2:单盘最高随机读写IOPS为10万。

  • PL3:单盘最高随机读写IOPS为100万。

有关如何选择ESSD性能等级,请参见ESSD云盘

Description

String

数据盘描述。

长度为2~256个字符。不能以http://https://开头。

Device

String

数据盘挂载点。

如果该参数值未指定,则默认将在自动创建ECS实例时由系统分配,取值从/dev/xvdb开始,到/dev/xvdz结束。

SnapshotId

String

创建数据盘时使用的快照。

指定该参数后,Size会被忽略,实际创建的磁盘大小为指定快照的大小。如果快照创建于2013年7月15日或之前,调用快照会被拒绝,返回参数中会提示InvalidSnapshot.TooOld。

Encrypted

String

数据盘是否加密。

取值:

  • true:加密。

  • false(默认值):不加密。

KMSKeyId

String

数据盘对应的KMS密钥ID。

AutoSnapshotPolicyId

String

数据盘使用的自动快照策略ID。

TagList语法

"TagList": [
  {
    "Key": String,
    "Value": String
  }
]

TagList属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

标签键。

长度为1~64个字符,不能以aliyunacs:开头,不能包含http://https://

Value

String

标签值。

长度为0~128个字符,不能以aliyunacs:开头,不能包含http://https://

返回值

Fn::GetAtt

  • ScalingConfigurationId:伸缩配置的ID。由系统生成,全局唯一。

  • ScalingGroupId:伸缩配置所属的伸缩组ID。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Description: Test ESS ScalingConfiguration
    Parameters:
      AutoScalingGroupId:
        Type: String
        AssociationProperty: ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId
      SecurityGroupId:
        Type: String
        AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
        Label:
          zh-cn: 安全组ID
          en: Security Group ID
      ImageId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Image::ImageId
        AssociationPropertyMetadata:
          SupportedImageOwnerAlias:
            - system
            - self
            - others
    Resources:
      ScalingConfiguration:
        Type: ALIYUN::ESS::ScalingConfiguration
        Properties:
          InstanceType: ecs.c5.large
          ImageId:
            Ref: ImageId
          SystemDiskCategory: cloud_essd
          SystemDiskSize: 40
          ScalingConfigurationName: mytest
          ScalingGroupId:
            Ref: AutoScalingGroupId
          SecurityGroupId:
            Ref: SecurityGroupId
    Outputs: {}
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Description": "Test ESS ScalingConfiguration",
      "Parameters": {
        "AutoScalingGroupId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId"
        },
        "SecurityGroupId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
          "Label": {
            "zh-cn": "安全组ID",
            "en": "Security Group ID"
          }
        },
        "ImageId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
          "AssociationPropertyMetadata": {
            "SupportedImageOwnerAlias": ["system", "self", "others"]
          }
        }
      },
      "Resources": {
        "ScalingConfiguration": {
          "Type": "ALIYUN::ESS::ScalingConfiguration",
          "Properties": {
            "InstanceType": "ecs.c5.large",
            "ImageId": {
              "Ref": "ImageId"
            },
            "SystemDiskCategory": "cloud_essd",
            "SystemDiskSize": 40,
            "ScalingConfigurationName": "mytest",
            "ScalingGroupId": {
              "Ref": "AutoScalingGroupId"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroupId"
            }
          }
        }
      },
      "Outputs": {
      }
    }

当伸缩组中仅定义了一个伸缩组配置,且伸缩组配置中包含依赖的其他资源,您需要在定义资源模板时为伸缩组设置DependsOn属性,对伸缩组配置依赖的其他资源设置资源依赖关联。

伸缩组ScalingGroup设置DependsOn依赖关系到安全组SecurityGroup,因为伸缩组配置ScalingConfiguration依赖安全组SecurityGroup资源。

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
  VSwitchId:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    Type: String
    AssociationPropertyMetadata:
      VpcId: VpcId
Resources:
  ScalingGroupEnable:
    Type: ALIYUN::ESS::ScalingGroupEnable
    Properties:
      ScalingConfigurationId:
        Ref: ScalingConfiguration
      ScalingGroupId:
        Ref: ScalingGroup
      ScalingRuleArisExecuteVersion: 0
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupName:
        Ref: ALIYUN::StackName
      VpcId:
        Ref: VpcId
      SecurityGroupIngress:
        - PortRange: '-1/-1'
          Priority: 1
          SourceCidrIp: 0.0.X.X/0
          IpProtocol: all
          NicType: internet
      SecurityGroupEgress:
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.X.X/0
          NicType: internet
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.X.X/0
          NicType: intranet
  ScalingConfiguration:
    Type: ALIYUN::ESS::ScalingConfiguration
    DependsOn: ScalingGroup
    Properties:
      InstanceType: ecs.g6e.large
      ImageId: centos_7_04_64_20G_alibase_201701015.vhd
      SystemDiskCategory: cloud_essd
      SystemDiskSize: 100
      ScalingConfigurationName:
        Ref: ALIYUN::StackName
      ScalingGroupId:
        Ref: ScalingGroup
      SecurityGroupId:
        Ref: SecurityGroup
  ScalingGroup:
    Type: ALIYUN::ESS::ScalingGroup
    DependsOn: SecurityGroup
    Properties:
      MaxSize: 3
      MinSize: 0
      DefaultCooldown: 15
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
Outputs: {}

更多示例,请参见创建伸缩配置和启用伸缩组的组合示例:JSON示例YAML示例