ACS-ECS-ScheduleToStopAndStartInstances
模板名稱
ACS-ECS-ScheduleToStopAndStartInstances 定時停止和開啟ECS實例
模板描述
定時停止和開啟ECS實例。
模板類型
自動化
所有者
Alibaba Cloud
輸入?yún)?shù)
參數(shù)名稱 | 描述 | 類型 | 是否必填 | 默認(rèn)值 | 約束 |
dailyStopTime | 每天停止實例的時間 | String | 是 | ||
dailyStartTime | 每天開啟實例的時間 | String | 是 | ||
targets | 目標(biāo)實例 | Json | 是 | ||
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} | |
weekdays | 任務(wù)執(zhí)行的周期 | String | 否 | MON-FRI | |
triggerEndDate | 時間觸發(fā)器結(jié)束時間 | String | 否 | 2099-12-01T00:00:00Z | |
stoppedMode | 停機收費模式 | String | 否 | “” | |
hibernate | 實例是否休眠 | Boolean | 否 | False | |
rateControl | 任務(wù)執(zhí)行的并發(fā)比率 | Json | 否 | {‘Mode’: ‘Concurrency’, ‘MaxErrors’: ‘100%’, ‘Concurrency’: 10} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | AliyunServiceRoleForOOSInstanceScheduler |
輸出參數(shù)
無
執(zhí)行此模板需要的權(quán)限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ECS-ScheduleToStopAndStartInstances詳情
模板內(nèi)容
FormatVersion: OOS-2019-06-01
Description:
en: Schedule to stop and start ECS instances.
zh-cn: 定時停止和開啟ECS實例。
name-en: ACS-ECS-ScheduleToStopAndStartInstances
name-zh-cn: 定時停止和開啟ECS實例
categories:
- time_trigger
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
dailyStopTime:
Label:
en: DailyStopTime
zh-cn: 每天停止實例的時間
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'HH:mm:ssZ'
dailyStartTime:
Label:
en: DailyStartTime
zh-cn: 每天開啟實例的時間
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'HH:mm:ssZ'
weekdays:
Label:
en: Weekdays
zh-cn: 任務(wù)執(zhí)行的周期
Description:
en: '* indicates daily, MON indicates Monday only, MON-FRI indicates Monday to Friday,refer them here: http://m.bestwisewords.com/document_detail/169784.html'
zh-cn: '*表示每天,MON表示僅周一,MON-FRI表示周一到周五。詳情參考:http://m.bestwisewords.com/document_detail/169784.html'
Type: String
Default: MON-FRI
triggerEndDate:
Label:
en: TriggerEndDate
zh-cn: 時間觸發(fā)器結(jié)束時間
Description:
en: 'Format: yyyy-MM-ddTHH:mm:ssZ.'
zh-cn: '格式:yyyy-MM-ddTHH:mm:ssZ'
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'YYYY-MM-DDTHH:mm:ssZ'
Default: '2099-12-01T00:00:00Z'
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: 目標(biāo)實例
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
stoppedMode:
Label:
en: StoppedMode
zh-cn: 停機收費模式
Description:
en: Indicates whether the ECS instance is still charged after it is stopped
zh-cn: 停止按量付費ECS實例后,是否繼續(xù)計費
Type: String
AllowedValues:
- StopCharging
- KeepCharging
- ''
Default: ''
hibernate:
Label:
en: WhetherToHibernateTheInstance
zh-cn: 實例是否休眠
Type: Boolean
Default: false
rateControl:
Label:
en: RateControl
zh-cn: 任務(wù)執(zhí)行的并發(fā)比率
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100%
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: AliyunServiceRoleForOOSInstanceScheduler
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: 'ACS::TimerTrigger'
Description:
en: Triggers a task as scheduled by specifying Cron expression
zh-cn: 通過指定Cron表達式按計劃觸發(fā)任務(wù)
Properties:
Type: cron
EndDate: '{{ triggerEndDate }}'
Expression:
'Fn::Join':
- ' '
- - '0'
- 'Fn::Select':
- 1
- 'Fn::Split':
- ':'
- '{{ dailyStopTime }}'
- 'Fn::Select':
- 0
- 'Fn::Split':
- ':'
- '{{ dailyStopTime }}'
- '?'
- '*'
- '{{ weekdays }}'
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: 獲取ECS實例
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{regionId}}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: stopInstance
Action: 'ACS::ECS::StopInstance'
Description:
en: Stops the ECS instances
zh-cn: 停止實例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
stoppedMode: '{{ stoppedMode }}'
hibernate: '{{ hibernate }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
- Name: sleepToSpecifiedTime
Description:
en: Sleep to instance start time
zh-cn: 睡眠到實例開啟時間
Action: 'ACS::Sleep'
Properties:
Duration:
'Fn::DurationBetween':
- '{{ dailyStopTime }}'
- '{{ dailyStartTime }}'
- Name: startInstance
Action: 'ACS::ECS::StartInstance'
Description:
en: Starts the ECS instances
zh-cn: 開啟實例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
文檔內(nèi)容是否對您有幫助?