Nome do modelo
ACS-ECS-ScheduleToStopAndStartInstances: Agenda a parada e a inicialização de instâncias ECS
Descrição do modelo
Este modelo para e inicia instâncias do Elastic Compute Service (ECS) conforme uma programação definida para automatizar tarefas de O&M e gerenciar recursos. Configure os parâmetros necessários: ID da região (regionId), horário diário de parada (dailyStopTime), horário diário de início (dailyStartTime), dias da semana (weekdays) e instâncias de destino (targets). Você também pode optar por hibernar as instâncias. O modelo então para e inicia as instâncias ECS seguindo o cronograma estabelecido.
Tipo de modelo
Automação
Proprietário
Alibaba Cloud
Parâmetros de entrada
|
Nome do parâmetro |
Descrição |
Tipo |
Obrigatório |
Valor padrão |
Restrições |
|
dailyStopTime |
Horário diário de parada das instâncias. |
String |
Sim |
||
|
dailyStartTime |
Horário diário de início das instâncias. |
String |
Sim |
||
|
targets |
Instâncias ECS alvo da operação. |
Json |
Sim |
||
|
regionId |
ID da região. |
String |
Não |
{{ ACS::RegionId }} |
|
|
weekdays |
Dias da semana de execução da tarefa. |
String |
Não |
MON-FRI |
|
|
triggerEndDate |
Data e hora de expiração do gatilho. |
String |
Não |
2099-12-01T00:00:00Z |
|
|
stoppedMode |
Modo de faturamento para instâncias paradas com pagamento conforme o uso. |
String |
Não |
"" |
|
|
hibernate |
Define se a instância deve ser hibernada. |
Boolean |
Não |
False |
|
|
rateControl |
Taxa de concorrência para execução da tarefa. |
Json |
Não |
{'Mode': 'Concurrency', 'MaxErrors': '100%', 'Concurrency': 10} |
|
|
OOSAssumeRole |
Função RAM assumida pelo Operation Orchestration Service (OOS). |
String |
Não |
AliyunServiceRoleForOOSInstanceScheduler |
Parâmetros de saída
Nenhum
Política de acesso necessária
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Detalhes
Para mais informações, consulte ACS-ECS-ScheduleToStopAndStartInstances.
Conteúdo do modelo
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 }}'