すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-ModifyInstanceSpec

最終更新日:Jan 17, 2025

テンプレート名

ACS-ECS-ModifyInstanceSpec

今すぐ実行

テンプレートの説明

従量課金制の Elastic Compute Service (ECS) インスタンスのインスタンスタイプを変更します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

instanceId

ECS インスタンスの ID。

String

はい

modifyInstanceSpecInfo

ECS インスタンスのインスタンスタイプを変更するために使用される情報。

Json

はい

regionId

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

OOSAssumeRole

CloudOps Orchestration Service (OOS) がアシュームする Resource Access Management (RAM) ロール。

String

いいえ

""

出力パラメーター

パラメーター

説明

タイプ

instanceIdAndInstanceType

List

テンプレートを実行するために必要な権限ポリシー

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

参照

詳細については、GitHub の ACS-ECS-ModifyInstanceSpec.yml をご参照ください。

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Modify postpaid instance's type
  zh-cn: the description in Chinese
  name-en: ACS-ECS-ModifyInstanceSpec
  name-zh-cn: the description in Chinese
  categories:
    - instance_manage
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: the description in Chinese
    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: |
        the description in Chinese
         
    Label:
      en: ModifyInstanceSpecInfo
      zh-cn: the description in Chinese
    Type: Json
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstanceType
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query instance type
      zh-cn: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceType:
        'Fn::Select':
          - '{{ getInstanceType.instanceType }}'
          - '{{ modifyInstanceSpecInfo }}'
  - Name: describeInstances
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query ECS instances info
      zh-cn: the description in Chinese
    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: the description in Chinese
            en: Parameter Configure
      - Parameters:
          - regionId
          - instanceId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options