Template name
ACS-ECS-BulkyStopInstances: Batch Stop Instances
Template description
Stops multiple Elastic Compute Service (ECS) instances at once. This helps optimize resources and manage costs. During configuration, you must specify the region ID (regionId) and the target instances (targets). After the template is executed, it returns a list of IDs for the stopped instances. This lets you verify the status of the instances.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | Target instance | Json | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
stoppedMode | The stop mode. | String | No | KeepCharging | |
forceStop | Specifies whether to forcibly stop the ECS instances. | Boolean | No | False | |
rateControl | Task execution concurrency | Json | No | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
instanceIds | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-BulkyStopInstances.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: 'Stops multiple ECS instances at once. This is useful for optimizing resources and managing costs. You must specify the region ID (regionId) and target instances (targets). The template returns a list of stopped instance IDs for verification.'
name-en: 'Bulky Stop Instances'
categories:
- instance_manage
- application_manage
- computenest
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: TargetInstance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
stoppedMode:
Description:
en: For details about StoppedMode, see the <a href="https://www.alibabacloud.com/help/document_detail/25501.html" target="_blank">documentation</a>.
Label:
en: StoppedMode
Type: String
Default: KeepCharging
AssociationProperty: ALIYUN::ECS::Instance::StopMode
forceStop:
Label:
en: ForceStop
Type: Boolean
Default: false
rateControl:
Label:
en: RateControl
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Views the ECS instances
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
- Name: stopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instances
Properties:
regionId: '{{ regionId }}'
stoppedMode: '{{ stoppedMode }}'
instanceId: '{{ ACS::TaskLoopItem }}'
forceStop: '{{ forceStop }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.Instances.Instance[].InstanceId }}'
Outputs:
instanceIds:
Type: List
Value: '{{ getInstance.Instances.Instance[].InstanceId }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- stoppedMode
Label:
default:
en: Configure Parameters
- Parameters:
- regionId
- targets
Label:
default:
en: Select ECS Instances
- Parameters:
- forceStop
- rateControl
- OOSAssumeRole
Label:
default:
en: Control Options