Template name
ACS-ECS-ModifyInstanceSpec
Template description
Changes the instance type of a pay-as-you-go Elastic Compute Service (ECS) instance.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
instanceId | The ID of the ECS instance. | String | Yes | ||
modifyInstanceSpecInfo | The information that is used to change the instance type of the ECS instance. | Json | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
instanceIdAndInstanceType | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstanceTypes",
"ecs:DescribeInstances",
"ecs:ModifyInstanceSpec",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-ModifyInstanceSpec.yml at GitHub.
Template content
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