All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-ScheduleToRebootInstancesWithSLR

Last Updated:Nov 25, 2024

Template name

ACS-ECS-ScheduleToRebootInstancesWithSLR

Execute Now

Template description

Restarts Elastic Compute Service (ECS) instances as scheduled.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

timerTrigger

The type of the scheduled task.

Json

Yes

targets

The ECS instances to be restarted.

Json

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

rateControl

The rate control settings.

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

AliyunServiceRoleForOOSInstanceScheduler

Output parameters

Parameter

Description

Type

instanceIds

List

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:RebootInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

For more information, see ACS-ECS-ScheduleToStartAndStopInstances.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Schedule to reboots the ECS instances
  zh-cn: the description in Chinese
  name-en: ACS-ECS-ScheduleToRebootInstancesWithSLR
  name-zh-cn: the description in Chinese
  categories:
    - time_trigger
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  timerTrigger:
    Type: Json
    Label:
      en: TimerTrigger
      zh-cn: the description in Chinese
    AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
    AssociationPropertyMetadata:
      MinuteInterval: 30
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: the description in Chinese
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: AliyunServiceRoleForOOSInstanceScheduler
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
  Action: ACS::TimerTrigger
  Description:
    en: Triggers a task as scheduled by specifying type and expression
    zh-cn: the description in Chinese
  Properties:
    Type:
      Fn::Select:
        - type
        - '{{timerTrigger}}'
    Expression:
      Fn::Select:
        - expression
        - '{{timerTrigger}}'
    EndDate:
      Fn::Select:
        - endDate
        - '{{ timerTrigger }}'
    TimeZone:
      Fn::Select:
        - timeZone
        - '{{ timerTrigger }}'
- Name: getInstance
  Description:
    en: Views the ECS instances
    zh-cn: the description in Chinese
  Action: ACS::SelectTargets
  Properties:
    ResourceType: ALIYUN::ECS::Instance
    RegionId: '{{ regionId }}'
    Filters:
      - '{{ targets }}'
  Outputs:
    instanceIds:
      Type: List
      ValueSelector: Instances.Instance[].InstanceId
- Name: rebootInstance
  Action: ACS::ECS::RebootInstance
  Description:
    en: Restarts the ECS instances
    zh-cn: the description in Chinese
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ ACS::TaskLoopItem }}'
  Loop:
    Items: '{{ getInstance.instanceIds }}'
    RateControl: '{{ rateControl }}'
Outputs:
  instanceIds:
    Type: List
    Value: '{{ getInstance.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - timerTrigger
        Label:
          default:
            zh-cn: the description in Chinese
            en: Timer Trigger Configure
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select ECS Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options