Template name
ACS-ECS-BulkyStopClassicInstances - Batch stop ECS instances in the classic network
Template description
Batch stops classic network-connected Elastic Compute Service (ECS) instances.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
|
Parameter |
Description |
Type |
Required |
Default value |
Limit |
|
targets |
The ECS instances to be stopped. |
Json |
Yes |
||
|
regionId |
The region ID. |
String |
No |
{{ ACS::RegionId }} |
|
|
stoppedMode |
The stop mode. |
String |
No |
KeepCharging |
|
|
rateControl |
The concurrency settings for task execution. |
Json |
No |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
|
|
OOSAssumeRole |
The RAM role 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-BulkyStopClassicInstances.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulk-stops classic network ECS instances.
zh-cn: Bulk-stops classic network ECS instances.
name-en: ACS-ECS-BulkStopClassicInstances
name-zh-cn: BulkStopClassicInstances
categories:
- instance_manage
Parameters:
regionId:
Type: String
Label:
en: Region ID
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: Target Instance
zh-cn: Target Instance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
stoppedMode:
Description:
en: Specifies whether to continue billing for a pay-as-you-go ECS instance after it is stopped. For more information about StoppedMode, see the <a href="https://www.alibabacloud.com/help/document_detail/25501.html" target="_blank">documentation</a>.
zh-cn: Specifies whether to continue billing for a pay-as-you-go ECS instance after it is stopped. For more information about StoppedMode, see the <a href="https://www.alibabacloud.com/help/document_detail/25501.html" target="_blank">documentation</a>.
Label:
en: Stopped Mode
zh-cn: Stopped Mode
Type: String
AllowedValues:
- StopCharging
- KeepCharging
Default: KeepCharging
AssociationPropertyMetadata:
LocaleKey: ECSStoppedMode
rateControl:
Label:
en: Concurrency Rate
zh-cn: Concurrency Rate
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: RAM Role for OOS
zh-cn: RAM Role for OOS
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Retrieves the ECS instances.
zh-cn: Retrieves the ECS instances.
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: .Instances.Instance | map(select( .InstanceNetworkType == "classic")) | .[].InstanceId
- Name: stopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stops the instances.
zh-cn: Stops the instances.
Properties:
regionId: '{{ regionId }}'
stoppedMode: '{{ stoppedMode }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
instanceIds:
Type: List
Value: '{{ getInstance.instanceIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- stoppedMode
Label:
default:
zh-cn: Configure Parameters
en: Configure Parameters
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: Select ECS Instances
en: Select ECS Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced Options
en: Advanced Options