All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-ModifyInstanceSpec

Last Updated:Jun 04, 2026

Template name

ACS-ECS-ModifyInstanceSpec: Modify the instance type of a pay-as-you-go instance.

Execute Now

Description

Modify the instance type of a pay-as-you-go ECS instance.

Template type

Automation

Owner

Alibaba Cloud

Input parameters

Parameter name

Description

Type

Required

Default value

Constraint

instanceId

ECS instance ID.

String

Yes

modifyInstanceSpecInfo

Instance type mapping for upgrade or downgrade.

Json

Yes

regionId

Region ID.

String

No

{{ ACS::RegionId }}

OOSAssumeRole

RAM role assumed by OOS.

String

No

“”

Output parameters

Parameter name

Description

Type

instanceIdAndInstanceType

List

Required access policy

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

Details

ACS-ECS-ModifyInstanceSpec details

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Modifies the instance type of a pay-as-you-go instance.
  zh-cn: Modifies the instance type of a pay-as-you-go instance.
  name-en: ACS-ECS-ModifyInstanceSpec
  name-zh-cn: Modifies the instance type of a pay-as-you-go instance.
  categories:
    - instance_manage
Parameters:
  regionId:
    Label:
      en: Region ID
      zh-cn: Region ID
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: ECS Instance ID
      zh-cn: ECS Instance 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: |
        Upgrade format: {"ecs.g6.large":"ecs.g6.xlarge", "ecs.g6.xlarge":"ecs.g6.2xlarge"}
        Downgrade format: {"ecs.g6.2xlarge":"ecs.g6.xlarge", "ecs.g6.xlarge":"ecs.g6.large"}
    Label:
      en: Instance Type Information
      zh-cn: The instance type information for upgrading or downgrading the instance.
    Type: Json
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes.
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstanceType
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Queries the instance type.
      zh-cn: Queries the instance type.
    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: Checks whether the resource exists.
      zh-cn: Checks whether the resource exists.
    Properties:
      DefaultTask: checkForInstanceTypeAvailable
      Choices:
        - When:
            Fn::Equals:
              - []
              - '{{ getInstanceType.instanceIds }}'
          NextTask: ACS::END
  - Name: checkForInstanceTypeAvailable
    Action: ACS::CheckFor
    Description:
      en: Checks whether the instance type is available.
      zh-cn: Checks whether the instance type is available.
    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: Modifies the instance type.
      zh-cn: Modifies the instance type.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceType:
        'Fn::Select':
          - '{{ getInstanceType.instanceType }}'
          - '{{ modifyInstanceSpecInfo }}'
  - Name: describeInstances
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Queries information about the ECS instances.
      zh-cn: Queries information about the ECS instances.
    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: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - regionId
          - instanceId
        Label:
          default:
            zh-cn: Select Instances
            en: Select Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced Options
            en: Advanced Options