全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ECS-ScheduleToStartInstances

更新時間:Sep 06, 2024

模板名稱

ACS-ECS-ScheduleToStartInstances 定時啟動ECS執行個體

立即執行

模板描述

定時啟動ECS執行個體

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

endDate

時間觸發器結束時間

String

targets

目標執行個體

Json

regionId

地區ID

String

{{ ACS::RegionId }}

cron

cron運算式

String

0 0 12 ? * *

timeZone

時區

String

UTC

rateControl

任務執行的並發比率

Json

{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 10}

OOSAssumeRole

OOS扮演的RAM角色

String

OOSServiceRole

輸出參數

參數名稱

描述

類型

instanceIds

List

執行此模板需要的權限原則

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

詳情

ACS-ECS-ScheduleToStartInstances詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  en: Schedule to starts the ECS instances
  zh-cn: 定時啟動ECS執行個體
  name-en: ACS-ECS-ScheduleToStartInstances
  name-zh-cn: 定時啟動ECS執行個體
  categories:
    - time_trigger
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地區ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  cron:
    Description:
      en: 'refer them here: https://help.aliyun.com/document_detail/169784.html'
      zh-cn: '詳情參考:https://help.aliyun.com/document_detail/169784.html'
    Label:
      en: CronExpression
      zh-cn: cron運算式
    Type: String
    AssociationProperty: Cron
    Default: 0 0 12 ? * *
  endDate:
    Description:
      en: 'Format: yyyy-MM-ddTHH:mm:ssZ.'
      zh-cn: '格式:yyyy-MM-ddTHH:mm:ssZ'
    Label:
      en: EndDate
      zh-cn: 時間觸發器結束時間
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: 'YYYY-MM-DDTHH:mm:ssZ'
  timeZone:
    Label:
      en: TimeZone
      zh-cn: 時區
    Type: String
    AssociationProperty: TimeZone
    Default: UTC
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: 目標執行個體
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  rateControl:
    Label:
      en: RateControl
      zh-cn: 任務執行的並發比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
  Action: ACS::TimerTrigger
  Description:
    en: Triggers a task as scheduled by specifying type and expression
    zh-cn: 通過指定觸發類型和運算式按計劃觸發任務
  Properties:
    Type: cron
    Expression: '{{ cron }}'
    EndDate: '{{ endDate }}'
    TimeZone: '{{ timeZone }}'
- Name: getInstance
  Description:
    en: Views the ECS instances.
    zh-cn: 擷取ECS執行個體。
  Action: ACS::SelectTargets
  Properties:
    ResourceType: ALIYUN::ECS::Instance
    RegionId: '{{ regionId }}'
    Filters:
      - '{{ targets }}'
  Outputs:
    instanceIds:
      Type: List
      ValueSelector: Instances.Instance[].InstanceId
- Name: startInstance
  Action: ACS::ECS::StartInstance
  Description:
    en: Starts the ECS instances.
    zh-cn: 啟動執行個體。
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ ACS::TaskLoopItem }}'
  Loop:
    RateControl: '{{ rateControl }}'
    Items: '{{ getInstance.instanceIds }}'
Outputs:
  instanceIds:
    Type: List
    Value: '{{ getInstance.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - timeZone
          - cron
          - endDate
        Label:
          default:
            zh-cn: 定時設定
            en: Timer Trigger Configure
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 選擇執行個體
            en: Select ECS Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 進階選項
            en: Control Options