すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-ScheduleToStartAndStopInstances

最終更新日:Dec 21, 2025

テンプレート名

ACS-ECS-ScheduleToStartAndStopInstances - ECS インスタンスの起動と停止をスケジュール

今すぐ実行

テンプレートの説明

Elastic Compute Service (ECS) インスタンスをスケジュールに基づいて起動および停止します。このテンプレートは、開発環境の自動 O&M やコスト最適化など、ECS インスタンスの定期的な管理が必要なシナリオで役立ちます。設定時には、インスタンスのリージョン ID (`regionId`)、毎日の起動時刻 (`dailyStartTime`)、毎日の停止時刻 (`dailyStopTime`)、曜日 (`weekdays`) といったスケジューリングルールを定義するための必須パラメーターを指定する必要があります。実行後、テンプレートは設定されたスケジュールに基づいて ECS インスタンスを起動および停止します。

テンプレートの種類

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

種類

必須

デフォルト値

制限

dailyStartTime

毎日 ECS インスタンスを起動する時刻。

String

はい

dailyStopTime

毎日 ECS インスタンスを停止する時刻。

String

はい

targets

ターゲットインスタンス

Json

はい

regionId

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

weekdays

スケジュールされたタスクのサイクル。

String

いいえ

MON-FRI

triggerEndDate

スケジュールされたタスクの終了時刻。

String

いいえ

2099-12-01T00:00:00Z

stoppedMode

停止したインスタンスの課金

String

いいえ

""

hibernate

ECS インスタンスをハイバネートするかどうかを指定します。

Boolean

いいえ

False

rateControl

タスク実行の同時実行数

Json

いいえ

{'Mode': 'Concurrency', 'MaxErrors': '100%', 'Concurrency': 10}

OOSAssumeRole

CloudOps Orchestration Service ( OOS ) によって引き受けられる Resource Access Management ( RAM ) ロール。

String

いいえ

AliyunServiceRoleForOOSInstanceScheduler

出力パラメーター

なし

テンプレートを実行するために必要な権限ポリシー

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

詳細

詳細については、「ACS-ECS-ScheduleToStartAndStopInstances」をご参照ください。

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: 'ECS インスタンスの起動と停止をスケジュールします。開発環境の自動運用やコスト最適化など、ECS インスタンスの定期的かつスケジュールされた管理が必要なシナリオに適用されます。設定時には、操作対象の ECS インスタンスのリージョンを指定するリージョン ID (regionId)、毎日の起動時刻 (dailyStartTime)、毎日の停止時刻 (dailyStopTime)、およびタスクのスケジュールを定義する曜日 (weekdays) といった必須パラメーター情報を提供する必要があります。実行後、テンプレートは設定されたスケジュールに従って ECS インスタンスを起動および停止します。'
  zh-cn: 'Schedule to start and stop ECS instances, applicable to scenarios where regular and scheduled management of ECS instances is required, such as automated operations of development environments and cost optimization. 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 Start Time (dailyStartTime), Daily Stop Time (dailyStopTime), and the Days of Week (weekdays), which define the schedule for the tasks. Upon execution, the template will start and stop the ECS instances according to the configured schedule.'
  name-en: ACS-ECS-ScheduleToStartAndStopInstances
  name-zh-cn: Schedule to Start and Stop ECS Instances
  categories:
    - time_trigger
Parameters:
  regionId:
    Type: String
    Label:
      en: リージョン ID
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  dailyStartTime:
    Label:
      en: 毎日の起動時刻
      zh-cn: Daily start time
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: 'HH:mm:ssZ'
  dailyStopTime:
    Label:
      en: 毎日の停止時刻
      zh-cn: Daily stop time
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: 'HH:mm:ssZ'
  weekdays:
    Label:
      en: 曜日
      zh-cn: Weekdays
    Description:
      en: '「*」は毎日、「MON」は月曜日のみ、「MON-FRI」は月曜日から金曜日までを示します。詳細については、https://www.alibabacloud.com/help/document_detail/169784.html をご参照ください。'
      zh-cn: '* indicates daily, MON indicates Monday only, and 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: トリガーの終了日
      zh-cn: Trigger end date
    Description:
      en: 'フォーマット: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: ターゲットインスタンス
      zh-cn: Target instance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  stoppedMode:
    Label:
      en: 停止モード
      zh-cn: Stopped mode
    Description:
      en: 従量課金制の ECS インスタンスが停止された後も課金を継続するかどうかを指定します。
      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: インスタンスの休止
      zh-cn: Hibernate instance
    Type: Boolean
    Default: false
  rateControl:
    Label:
      en: レート制御
      zh-cn: Rate control
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 100%
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOSAssumeRole
    Type: String
    Default: AliyunServiceRoleForOOSInstanceScheduler
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: timerTrigger
    Action: 'ACS::TimerTrigger'
    Description:
      en: cron 式を指定して、スケジュールされたタスクをトリガーします。
      zh-cn: Triggers a task as scheduled by specifying a cron expression.
    Properties:
      Type: cron
      EndDate: '{{ triggerEndDate }}'
      Expression:
        'Fn::Join':
          - ' '
          - - '0'
            - 'Fn::Select':
                - 1
                - 'Fn::Split':
                    - ':'
                    - '{{ dailyStartTime }}'
            - 'Fn::Select':
                - 0
                - 'Fn::Split':
                    - ':'
                    - '{{ dailyStartTime }}'
            - '?'
            - '*'
            - '{{ weekdays }}'
  - Name: getInstance
    Description:
      en: ECS インスタンスを取得します。
      zh-cn: Gets the ECS instances.
    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: ECS インスタンスを起動します。
      zh-cn: Starts the ECS instances.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
  - Name: sleepToSpecifiedTime
    Description:
      en: インスタンスの停止時刻までスリープします。
      zh-cn: Sleeps until the instance stop time.
    Action: 'ACS::Sleep'
    Properties:
      Duration:
        'Fn::DurationBetween':
          - '{{ dailyStartTime }}'
          - '{{ dailyStopTime }}'
  - Name: stopInstance
    Action: 'ACS::ECS::StopInstance'
    Description:
      en: ECS インスタンスを停止します。
      zh-cn: Stops the ECS instances.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      stoppedMode: '{{ stoppedMode }}'
      hibernate: '{{ hibernate }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'