Nama Template
ACS-ECS-ScheduleToStopAndStartInstances: Menjadwalkan penghentian dan pengaktifan instans ECS
Deskripsi Template
Templat ini menghentikan dan mengaktifkan instans Elastic Compute Service (ECS) sesuai jadwal, yang berguna untuk tugas Operations and Maintenance (O&M) otomatis serta manajemen sumber daya. Untuk menggunakan templat ini, konfigurasikan parameter yang diperlukan: ID wilayah (regionId), waktu berhenti harian (dailyStopTime), waktu mulai harian (dailyStartTime), hari dalam seminggu (weekdays), dan instans target (targets). Anda juga dapat memilih untuk menghibernasi instans tersebut. Templat ini kemudian akan menghentikan dan mengaktifkan instans ECS sesuai jadwal yang Anda tentukan.
Tipe Template
Automation
Pemilik
Alibaba Cloud
Parameter Input
Nama parameter | Deskripsi | Tipe | Diperlukan | Nilai Default | Batasan |
dailyStopTime | Waktu untuk menghentikan instans setiap hari. | String | Ya | ||
dailyStartTime | Waktu untuk mengaktifkan instans setiap hari. | String | Ya | ||
targets | Instans sasaran. | Json | Ya | ||
regionId | ID wilayah. | String | Tidak | {{ ACS::RegionId }} | |
weekdays | Hari dalam seminggu untuk menjalankan task. | String | Tidak | SEN-JUM | |
triggerEndDate | Waktu kedaluwarsa pemicu. | String | Tidak | 2099-12-01T00:00:00Z | |
stoppedMode | Mode penagihan untuk instans pay-as-you-go yang dihentikan. | String | Tidak | "" | |
hibernate | Menentukan apakah instans akan dihibernasi. | Boolean | Tidak | False | |
rateControl | Laju konkurensi untuk eksekusi task. | Json | Tidak | {'Mode': 'Concurrency', 'MaxErrors': '100%', 'Concurrency': 10} | |
OOSAssumeRole | Peran RAM yang diasumsikan oleh Operation Orchestration Service (OOS). | String | Tidak | AliyunServiceRoleForOOSInstanceScheduler |
Parameter Keluaran
Tidak ada
Kebijakan akses yang diperlukan
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Rincian
Untuk informasi selengkapnya, lihat ACS-ECS-ScheduleToStopAndStartInstances.
Konten Template
FormatVersion: OOS-2019-06-01
Description:
en: 'Schedules to stop and start ECS instances, applicable to scenarios that require automatically stopping and starting ECS instances at specific times, such as automated maintenance tasks and resource management. 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 Stop Time (dailyStopTime) and Daily Start Time (dailyStartTime), and Days of Week (weekdays), which define the schedule for the tasks, along with Target Instances (targets), which define the specific ECS instances to be operated on. Users can also choose whether to stop or hibernate the instances. The template will stop and start the ECS instances according to the configured schedule.'
zh-cn: 'Schedules to stop and start ECS instances. This template is applicable to scenarios that require automatically stopping and starting ECS instances at specific times, such as automated O&M tasks and resource management. During configuration, you must provide the following required parameters: Region ID (regionId), which specifies the region of the ECS instances to be operated on; Daily Stop Time (dailyStopTime) and Daily Start Time (dailyStartTime); Days of Week (weekdays), which defines the schedule for the tasks; and Target Instances (targets), which defines the specific ECS instances to be operated on. You can also choose whether to stop or hibernate the instances. The template will stop and start the ECS instances according to the configured schedule.'
name-en: ACS-ECS-ScheduleToStopAndStartInstances
name-zh-cn: Schedule to stop and start ECS instances
categories:
- time_trigger
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
dailyStopTime:
Label:
en: DailyStopTime
zh-cn: Daily stop time
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'HH:mm:ssZ'
dailyStartTime:
Label:
en: DailyStartTime
zh-cn: Daily start time
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'HH:mm:ssZ'
weekdays:
Label:
en: Weekdays
zh-cn: Task execution cycle
Description:
en: '* indicates daily, MON indicates Monday only, MON-FRI indicates Monday to Friday,refer them here: https://www.alibabacloud.com/help/document_detail/169784.html'
zh-cn: '* indicates daily, MON indicates Monday only, MON-FRI indicates Monday to Friday. For more information, see: https://www.alibabacloud.com/help/document_detail/169784.html'
Type: String
Default: MON-FRI
triggerEndDate:
Label:
en: TriggerEndDate
zh-cn: Trigger end time
Description:
en: 'Format: yyyy-MM-ddTHH:mm:ssZ.'
zh-cn: 'Format: 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: Target instance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
stoppedMode:
Label:
en: StoppedMode
zh-cn: Stopped mode
Description:
en: Indicates whether the ECS instance is still charged after it is stopped
zh-cn: Specifies whether to continue billing for a pay-as-you-go ECS instance after it is stopped.
Type: String
AllowedValues:
- StopCharging
- KeepCharging
- ''
Default: ''
hibernate:
Label:
en: WhetherToHibernateTheInstance
zh-cn: Whether to hibernate the instance
Type: Boolean
Default: false
rateControl:
Label:
en: RateControl
zh-cn: Task execution concurrency rate
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100%
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: RAM role assumed by OOS
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: Triggers a task on a schedule by specifying a cron expression.
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: Gets ECS instances.
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: Stops instances.
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: Sleeps until the instance start time.
Action: 'ACS::Sleep'
Properties:
Duration:
'Fn::DurationBetween':
- '{{ dailyStopTime }}'
- '{{ dailyStartTime }}'
- Name: startInstance
Action: 'ACS::ECS::StartInstance'
Description:
en: Starts the ECS instances
zh-cn: Starts instances.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'