Nom du modèle
ACS-ECS-ScheduleToStopAndStartInstances : Planifie l'arrêt et le démarrage des instances ECS
Description du modèle
Arrête et démarre les instances Elastic Compute Service (ECS) selon un planning défini pour automatiser les tâches d'exploitation et de maintenance ainsi que la gestion des ressources. Spécifiez les paramètres requis : ID de région (regionId), heure d'arrêt quotidienne (dailyStopTime), heure de démarrage quotidienne (dailyStartTime), jours de la semaine (weekdays) et instances cibles (targets). Vous pouvez également mettre les instances en veille prolongée. Le modèle arrête et démarre ensuite les instances ECS en respectant le planning configuré.
Type de modèle
Automatisation
Propriétaire
Alibaba Cloud
Paramètres d'entrée
|
Nom du paramètre |
Description |
Type |
Obligatoire |
Valeur par défaut |
Contraintes |
|
dailyStopTime |
Heure d'arrêt quotidienne des instances. |
String |
Oui |
||
|
dailyStartTime |
Heure de démarrage quotidienne des instances. |
String |
Oui |
||
|
targets |
Instances ECS à traiter. |
Json |
Oui |
||
|
regionId |
ID de la région. |
String |
Non |
{{ ACS::RegionId }} |
|
|
weekdays |
Jours de la semaine durant lesquels la tâche s'exécute. |
String |
Non |
MON-FRI |
|
|
triggerEndDate |
Date d'expiration du déclencheur. |
String |
Non |
2099-12-01T00:00:00Z |
|
|
stoppedMode |
Mode de facturation d'une instance arrêtée en paiement à l'utilisation. |
String |
Non |
"" |
|
|
hibernate |
Indique s'il faut mettre l'instance en veille prolongée. |
Boolean |
Non |
False |
|
|
rateControl |
Taux de concurrence pour l'exécution des tâches. |
Json |
Non |
{'Mode': 'Concurrency', 'MaxErrors': '100%', 'Concurrency': 10} |
|
|
OOSAssumeRole |
Rôle RAM utilisé par Operation Orchestration Service (OOS). |
String |
Non |
AliyunServiceRoleForOOSInstanceScheduler |
Paramètres de sortie
Aucun
Politique d'accès requise
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Détails
Pour plus d'informations, consultez ACS-ECS-ScheduleToStopAndStartInstances.
Contenu du modèle
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 }}'