ACS-ECS-ScheduleToStartAndStopInstances
模板名稱
ACS-ECS-ScheduleToStartAndStopInstances 定時(shí)開(kāi)啟和停止ECS實(shí)例
模板描述
定時(shí)開(kāi)啟和停止ECS實(shí)例,適用于需要定期管理和調(diào)度ECS實(shí)例的場(chǎng)景,例如開(kāi)發(fā)環(huán)境的自動(dòng)化運(yùn)維和成本優(yōu)化。在配置過(guò)程中,用戶需要提供以下必填參數(shù)信息:地域ID(regionId):用于指定操作實(shí)例的地域,每天開(kāi)啟實(shí)例的時(shí)間(dailyStartTime)、每天停止實(shí)例的時(shí)間(dailyStopTime)、任務(wù)執(zhí)行的周期(weekdays):用于定義任務(wù)的定時(shí)觸發(fā)規(guī)則。模板在執(zhí)行后會(huì)根據(jù)設(shè)置的時(shí)間表開(kāi)啟和停止ECS實(shí)例。
模板類型
自動(dòng)化
所有者
Alibaba Cloud
輸入?yún)?shù)
參數(shù)名稱 | 描述 | 類型 | 是否必填 | 默認(rèn)值 | 約束 |
dailyStartTime | 每天開(kāi)啟實(shí)例的時(shí)間 | String | 是 | ||
dailyStopTime | 每天停止實(shí)例的時(shí)間 | String | 是 | ||
targets | 目標(biāo)實(shí)例 | Json | 是 | ||
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} | |
weekdays | 任務(wù)執(zhí)行的周期 | String | 否 | MON-FRI | |
triggerEndDate | 時(shí)間觸發(fā)器結(jié)束時(shí)間 | String | 否 | 2099-12-01T00:00:00Z | |
stoppedMode | 停機(jī)收費(fèi)模式 | String | 否 | “” | |
hibernate | 實(shí)例是否休眠 | Boolean | 否 | False | |
rateControl | 任務(wù)執(zhí)行的并發(fā)比率 | Json | 否 | {‘Mode’: ‘Concurrency’, ‘MaxErrors’: ‘100%’, ‘Concurrency’: 10} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | AliyunServiceRoleForOOSInstanceScheduler |
輸出參數(shù)
無(wú)
執(zhí)行此模板需要的權(quán)限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ECS-ScheduleToStartAndStopInstances詳情
模板內(nèi)容
FormatVersion: OOS-2019-06-01
Description:
en: 'Schedule to start and stop ECS instances, applicable to scenarios where regular and scheduled management of ECS instances is required, such as automated operations of development environments and cost optimization. During configuration, users need to provide the following required parameter information: Region ID (regionId), which specifies the region of the ECS instances to be operated on, Daily Start Time (dailyStartTime), Daily Stop Time (dailyStopTime), and the Days of Week (weekdays), which define the schedule for the tasks. Upon execution, the template will start and stop the ECS instances according to the configured schedule.'
zh-cn: 定時(shí)開(kāi)啟和停止ECS實(shí)例,適用于需要定期管理和調(diào)度ECS實(shí)例的場(chǎng)景,例如開(kāi)發(fā)環(huán)境的自動(dòng)化運(yùn)維和成本優(yōu)化。在配置過(guò)程中,用戶需要提供以下必填參數(shù)信息:地域ID(regionId):用于指定操作實(shí)例的地域,每天開(kāi)啟實(shí)例的時(shí)間(dailyStartTime)、每天停止實(shí)例的時(shí)間(dailyStopTime)、任務(wù)執(zhí)行的周期(weekdays):用于定義任務(wù)的定時(shí)觸發(fā)規(guī)則。模板在執(zhí)行后會(huì)根據(jù)設(shè)置的時(shí)間表開(kāi)啟和停止ECS實(shí)例。
name-en: ACS-ECS-ScheduleToStartAndStopInstances
name-zh-cn: 定時(shí)開(kāi)啟和停止ECS實(shí)例
categories:
- time_trigger
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
dailyStartTime:
Label:
en: DailyStartTime
zh-cn: 每天開(kāi)啟實(shí)例的時(shí)間
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'HH:mm:ssZ'
dailyStopTime:
Label:
en: DailyStopTime
zh-cn: 每天停止實(shí)例的時(shí)間
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://bestwisewords.com/document_detail/169784.html'
zh-cn: '*表示每天,MON表示僅周一,MON-FRI表示周一到周五。詳情參考:http://bestwisewords.com/document_detail/169784.html'
Type: String
Default: MON-FRI
triggerEndDate:
Label:
en: TriggerEndDate
zh-cn: 時(shí)間觸發(fā)器結(jié)束時(shí)間
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)實(shí)例
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
stoppedMode:
Label:
en: StoppedMode
zh-cn: 停機(jī)收費(fèi)模式
Description:
en: Indicates whether the ECS instance is still charged after it is stopped
zh-cn: 停止按量付費(fèi)ECS實(shí)例后,是否繼續(xù)計(jì)費(fèi)
Type: String
AllowedValues:
- StopCharging
- KeepCharging
- ''
Default: ''
hibernate:
Label:
en: WhetherToHibernateTheInstance
zh-cn: 實(shí)例是否休眠
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: 通過(guò)指定Cron表達(dá)式按計(jì)劃觸發(fā)任務(wù)
Properties:
Type: cron
EndDate: '{{ triggerEndDate }}'
Expression:
'Fn::Join':
- ' '
- - '0'
- 'Fn::Select':
- 1
- 'Fn::Split':
- ':'
- '{{ dailyStartTime }}'
- 'Fn::Select':
- 0
- 'Fn::Split':
- ':'
- '{{ dailyStartTime }}'
- '?'
- '*'
- '{{ weekdays }}'
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: 獲取ECS實(shí)例
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{regionId}}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: startInstance
Action: 'ACS::ECS::StartInstance'
Description:
en: Starts the ECS instances
zh-cn: 開(kāi)啟實(shí)例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
- Name: sleepToSpecifiedTime
Description:
en: Sleep to instance stop time
zh-cn: 睡眠到實(shí)例停止時(shí)間
Action: 'ACS::Sleep'
Properties:
Duration:
'Fn::DurationBetween':
- '{{ dailyStartTime }}'
- '{{ dailyStopTime }}'
- Name: stopInstance
Action: 'ACS::ECS::StopInstance'
Description:
en: Stops the ECS instances
zh-cn: 停止實(shí)例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
stoppedMode: '{{ stoppedMode }}'
hibernate: '{{ hibernate }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'