Nama templat
ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances
Execute now
Deskripsi templat
Startup dan shutdown terjadwal
Jenis templat
Automation
Pemilik
Alibaba Cloud
Parameter input
Parameter | Deskripsi | Tipe | Wajib | Nilai default | Batasan |
targets | Instans target. | Json | Ya | | |
dailyStartTime | Waktu untuk memulai instans setiap hari. | String | Ya | | |
dailyStopTime | Waktu untuk menghentikan instans setiap hari. | String | Ya | | |
regionId | ID wilayah. | String | Tidak | {{ ACS::RegionId }} | |
startFirstOrStopFirst | Mode start/stop. | String | Tidak | StartFirst | |
weekdays | Hari dalam seminggu untuk menjalankan task. | String | Tidak | * | |
triggerEndDate | Waktu akhir untuk pemicu. | String | Tidak | 2099-12-01T00:00:00Z | |
stoppedMode | Mode berhenti. | String | Tidak | KeepCharging | |
hibernate | Menentukan apakah instans akan di-hibernate. | Boolean | Tidak | False | |
rateControl | Laju konkurensi untuk task. | Json | Tidak | {'Mode': 'Concurrency', 'MaxErrors': 0, '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
Detail ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances
Konten templat
Menentukan mode berhenti untuk Instance ECS bayar sesuai penggunaan. Nilai yang valid:
StopCharging<p>Menentukan mode berhenti untuk instans ECS pay-as-you-go. Nilai yang valid:</p><ul> <li><code="">StopCharging</code=""></li></ul>FormatVersion: OOS-2019-06-01
Description:
en: Schedules ECS instances to either start then stop, or stop then start.
zh-cn: Schedules ECS instances to either start then stop, or stop then start.
name-en: ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances
name-zh-cn: Scheduled start and stop or stop and start of instances
categories:
- time_trigger
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
startFirstOrStopFirst:
Type: String
Label:
en: Start or stop mode
zh-cn: Start or stop mode
Description:
en: 'The scheduled start and stop actions are a single task. If you create this task after its scheduled start time for the day, it will not run on that day.'
zh-cn: 'The scheduled start and stop actions are a single task. If you create this task after its scheduled start time for the day, it will not run on that day.'
AllowedValues:
- StartFirst
- StopFirst
Default: StartFirst
AssociationPropertyMetadata:
LocaleKey: OOSStopInstanceMode
weekdays:
Label:
en: Task execution cycle
zh-cn: Task execution cycle
Type: String
AssociationProperty: TimeTriggerWeekly
Default: '*'
AssociationPropertyMetadata:
Mode: '${startFirstOrStopFirst}'
StartTime: '${dailyStartTime}'
StopTime: '${dailyStopTime}'
dailyStartTime:
Label:
en: Daily start time
zh-cn: Daily start time
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: HH:mm:ssZ
dailyStopTime:
Label:
en: Daily stop time
zh-cn: Daily stop time
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: HH:mm:ssZ
triggerEndDate:
Label:
en: Trigger end time
zh-cn: Trigger end time
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: YYYY-MM-DDTHH:mm:ssZ
Default: '2099-12-01T00:00:00Z'
stoppedMode:
Label:
en: Stop mode
zh-cn: Stop mode
Description:
en: <p>The stop mode for pay-as-you-go ECS instances. Value:</p> <ul> <li><code="">StopCharging</code=""></li></ul>
zh-cn: <p>The stop mode for pay-as-you-go ECS instances. Value:</p> <ul> <li><code="">StopCharging</code=""></li></ul>
agar berlaku. Untuk informasi selengkapnya, lihat
Mode ekonomis untuk instans pay-as-you-go.Mode berhenti standar: Instans tetap dikenai biaya setelah dihentikan.
Mode ekonomis: Untuk persyaratan yang diperlukan agar StopCharging berlaku, lihat bagian Kondisi di Mode ekonomis untuk instans pay-as-you-go.Mode berhenti untuk instans pay-as-you-go. Nilai yang valid adalah:
- Mode ekonomis: Untuk persyaratan yang diperlukan agar
StopCharging berlaku, lihat bagian Kondisi di Mode ekonomis untuk instans pay-as-you-go. - Mode berhenti standar: Penagihan tetap berlangsung setelah instans dihentikan.
FormatVersion: OOS-2019-06-01
Description:
en: Starts and then stops, or stops and then starts, Elastic Compute Service (ECS) instances on a schedule.
Parameters:
regionId:
Label:
en: Region
Description:
en: The region where the ECS instances are located.
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Label:
en: Target Instance
Description:
en: The ECS instances to operate on.
Type: Json
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
startFirstOrStopFirst:
Label:
en: Start First or Stop First
Description:
en: Specifies whether to start the instances first or stop the instances first.
Type: String
AllowedValues:
- StartFirst
- StopFirst
Default: StartFirst
weekdays:
Label:
en: Weekdays
Description: 'en: The days of the week on which to execute the task. You can specify multiple days, separated by commas (,).'
Type: String
AllowedPattern: '^((([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN),)*([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)|^\*|^\?)$'
Default: 1,2,3,4,5
dailyStartTime:
Label:
en: Daily Start Time
Description: 'en: The time of day to start the instances. Use the HH:mm format. The time is in UTC.'
Type: String
AllowedPattern: '^([01]?[0-9]|2[0-3]):[0-5][0-9]$'
Default: '09:00'
dailyStopTime:
Label:
en: Daily Stop Time
Description: 'en: The time of day to stop the instances. Use the HH:mm format. The time is in UTC.'
Type: String
AllowedPattern: '^([01]?[0-9]|2[0-3]):[0-5][0-9]$'
Default: '18:00'
triggerEndDate:
Label:
en: Trigger End Date
Description: 'en: The end date of the scheduled task. The time is in UTC.'
Type: String
AllowedPattern: ^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]Z$
stoppedMode:
Label:
en: ECS Stopped Mode
Description: 'en: The stop mode for the pay-as-you-go instance. Valid values are StopCharging and KeepCharging. StopCharging: Economical mode. For the conditions required for this mode to take effect, see Economical mode for pay-as-you-go instances. KeepCharging: Standard stop mode. The instance continues to be charged after it is stopped.'
Type: String
AllowedValues:
- StopCharging
- KeepCharging
Default: KeepCharging
AssociationPropertyMetadata:
LocaleKey: ECSStoppedMode
hibernate:
Label:
en: Hibernate Instance
Type: Boolean
Default: false
rateControl:
Label:
en: Rate Control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOS Assume Role
Type: String
Default: AliyunServiceRoleForOOSInstanceScheduler
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: ACS::TimerTrigger
Description:
en: Triggers a task on a schedule using a cron expression.
Properties:
Type: cron
EndDate: '{{ triggerEndDate }}'
Expression:
Fn::Join:
- ' '
- - '0'
- Fn::Select:
- 1
- Fn::Split:
- ':'
- Fn::If:
- Fn::Equals:
- StartFirst
- '{{startFirstOrStopFirst}}'
- '{{ dailyStartTime }}'
- '{{ dailyStopTime }}'
- Fn::Select:
- 0
- Fn::Split:
- ':'
- Fn::If:
- Fn::Equals:
- StartFirst
- '{{startFirstOrStopFirst}}'
- '{{ dailyStartTime }}'
- '{{ dailyStopTime }}'
- '?'
- '*'
- '{{ weekdays }}'
- Name: getInstance
Description:
en: Retrieves the specified ECS instances.
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{regionId}}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: startInstanceFirst
Action: ACS::ECS::StartInstance
Description:
en: Starts the ECS instances first.
When:
Fn::Equals:
- StartFirst
- '{{startFirstOrStopFirst}}'
OnError: sleepToStopTime
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
- Name: sleepToStopTime
Action: ACS::Sleep
Description:
en: Pauses the execution until the specified instance stop time.
When:
Fn::Equals:
- StartFirst
- '{{startFirstOrStopFirst}}'
Properties:
Duration:
Fn::DurationBetween:
- '{{ dailyStartTime }}'
- '{{ dailyStopTime }}'
- Name: stopInstanceSecond
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instances.
When:
Fn::Equals:
- StartFirst
- '{{startFirstOrStopFirst}}'
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
stoppedMode: '{{ stoppedMode }}'
hibernate: '{{ hibernate }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
- Name: stopInstanceFirst
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instances first.
When:
Fn::Equals:
- StopFirst
- '{{startFirstOrStopFirst}}'
OnError: sleepToStartTime
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
stoppedMode: '{{ stoppedMode }}'
hibernate: '{{ hibernate }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
- Name: sleepToStartTime
Action: ACS::Sleep
Description:
en: Pauses the execution until the specified instance start time.
When:
Fn::Equals:
- StopFirst
- '{{startFirstOrStopFirst}}'
Properties:
Duration:
Fn::DurationBetween:
- '{{ dailyStopTime }}'
- '{{ dailyStartTime }}'
- Name: startInstance
Action: ACS::ECS::StartInstance
Description:
en: Starts the ECS instances.
When:
Fn::Equals:
- StopFirst
- '{{startFirstOrStopFirst}}'
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'