ACS-ECS-ModifyInstanceSpec

模板名称

ACS-ECS-ModifyInstanceSpec 修改按量付费实例的规格

立即执行

模板描述

修改按量付费实例的规格

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

instanceId

ECS实例ID

String

modifyInstanceSpecInfo

用于实例升降配的规格信息

Json

regionId

地域ID

String

{{ ACS::RegionId }}

OOSAssumeRole

OOS扮演的RAM角色

String

“”

输出参数

参数名称

描述

类型

instanceIdAndInstanceType

List

执行此模板需要的权限策略

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstanceTypes",
                "ecs:DescribeInstances",
                "ecs:ModifyInstanceSpec",
                "ecs:StartInstance",
                "ecs:StopInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

详情

ACS-ECS-ModifyInstanceSpec详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  en: Modify postpaid instance's type
  zh-cn: 修改按量付费实例的规格
  name-en: ACS-ECS-ModifyInstanceSpec
  name-zh-cn: 修改按量付费实例的规格
  categories:
    - instance_manage
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: 地域ID
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: ECS实例ID
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  modifyInstanceSpecInfo:
    Description:
      en: 'upgrade:{"ecs.g6.large":"ecs.g6.xlarge", "ecs.g6.xlarge":"ecs.g6.2xlarge"} downgrade:{"ecs.g6.2xlarge":"ecs.g6.xlarge","ecs.g6.xlarge":"ecs.g6.large"}'
      zh-cn: |
        升配格式:{"ecs.g6.large":"ecs.g6.xlarge", "ecs.g6.xlarge":"ecs.g6.2xlarge"}
        降配格式:{"ecs.g6.2xlarge":"ecs.g6.xlarge", "ecs.g6.xlarge":"ecs.g6.large"}
    Label:
      en: ModifyInstanceSpecInfo
      zh-cn: 用于实例升降配的规格信息
    Type: Json
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstanceType
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query instance type
      zh-cn: 获取实例规格信息
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceIds:
          - '{{ instanceId }}'
    Outputs:
      instanceType:
        Type: String
        ValueSelector: Instances.Instance[].InstanceType
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: checkForWhetherResourceExist
    Action: ACS::Choice
    Description:
      en: Check whether the resource exist
      zh-cn: 检查资源是否存在
    Properties:
      DefaultTask: checkForInstanceTypeAvailable
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ getInstanceType.instanceIds }}'
          NextTask: ACS::END
  - Name: checkForInstanceTypeAvailable
    Action: ACS::CheckFor
    Description:
      en: Check weather the instance type is available
      zh-cn: 检查实例规格是否可用
    Properties:
      Service: ECS
      API: DescribeInstanceTypes
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceTypes:
          - Fn::Select:
              - '{{ getInstanceType.instanceType }}'
              - '{{ modifyInstanceSpecInfo }}'
      NotDesiredValues:
        - []
      PropertySelector: InstanceTypes.InstanceType
  - Name: ModifyInstanceSpec
    Action: 'ACS::ECS::ModifyInstanceSpec'
    Description:
      en: Modify instance type
      zh-cn: 修改实例规格
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceType:
        'Fn::Select':
          - '{{ getInstanceType.instanceType }}'
          - '{{ modifyInstanceSpecInfo }}'
  - Name: describeInstances
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query ECS instances info
      zh-cn: 获取ECS实例信息
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceIds:
          - '{{ instanceId }}'
    Outputs:
      instanceIdAndInstanceType:
        Type: List
        ValueSelector: 'Instances.Instance[] | {"InstanceId": .InstanceId, "InstanceType" : .InstanceType}'
Outputs:
  instanceIdAndInstanceType:
    Type: List
    Value: '{{ describeInstances.instanceIdAndInstanceType }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - modifyInstanceSpecInfo
        Label:
          default:
            zh-cn: 设置参数
            en: Parameter Configure
      - Parameters:
          - regionId
          - instanceId
        Label:
          default:
            zh-cn: 选择实例
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options