Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances

Dernière mise à jour :Aug 11, 2026

Nom du modèle

ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances

Exécuter maintenant

Description du modèle

Démarre et arrête les instances ECS selon une planification.

Type de modèle

Automatisation

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Paramètre

Description

Type

Obligatoire

Valeur par défaut

Contraintes

targets

Les instances cibles.

Json

Oui

dailyStartTime

L'heure de démarrage des instances chaque jour.

String

Oui

dailyStopTime

L'heure d'arrêt des instances chaque jour.

String

Oui

regionId

L'ID de la région.

String

Non

{{ ACS::RegionId }}

startFirstOrStopFirst

Le mode de démarrage/arrêt.

String

Non

StartFirst

weekdays

Les jours de la semaine pour l'exécution de la tâche.

String

Non

*

triggerEndDate

L'heure de fin du déclencheur.

String

Non

2099-12-01T00:00:00Z

stoppedMode

Le mode d'arrêt.

String

Non

KeepCharging

hibernate

Indique si les instances doivent être mises en veille prolongée.

Boolean

Non

False

rateControl

Le taux de concurrence pour la tâche.

Json

Non

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

OOSAssumeRole

Le rôle RAM assumé 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

Détails ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances

Contenu du modèle

Specifies the stop mode for a pay-as-you-go ECS instance. Valid values:
Description:
  en: Schedules ECS instances to either start then stop, or stop then start.
  zh-cn: Schedules ECS instances to either start then stop, or stop then start.
  name-en: ACS-ECS-ScheduleToStartAndStopOrStopAndStartInstances
  name-zh-cn: Scheduled start and stop or stop and start of instances
  categories:
    - time_trigger
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: Target instance
      zh-cn: Target instance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
  startFirstOrStopFirst:
    Type: String
    Label:
      en: Start or stop mode
      zh-cn: Start or stop mode
    Description:
      en: 'The scheduled start and stop actions are a single task. If you create this task after its scheduled start time for the day, it will not run on that day.'
      zh-cn: 'The scheduled start and stop actions are a single task. If you create this task after its scheduled start time for the day, it will not run on that day.'
    AllowedValues:
      - StartFirst
      - StopFirst
    Default: StartFirst
    AssociationPropertyMetadata:
      LocaleKey: OOSStopInstanceMode
  weekdays:
    Label:
      en: Task execution cycle
      zh-cn: Task execution cycle
    Type: String
    AssociationProperty: TimeTriggerWeekly
    Default: '*'
    AssociationPropertyMetadata:
      Mode: '${startFirstOrStopFirst}'
      StartTime: '${dailyStartTime}'
      StopTime: '${dailyStopTime}'
  dailyStartTime:
    Label:
      en: Daily start time
      zh-cn: Daily start time
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: HH:mm:ssZ
  dailyStopTime:
    Label:
      en: Daily stop time
      zh-cn: Daily stop time
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: HH:mm:ssZ
  triggerEndDate:
    Label:
      en: Trigger end time
      zh-cn: Trigger end time
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: YYYY-MM-DDTHH:mm:ssZ
    Default: '2099-12-01T00:00:00Z'
  stoppedMode:
    Label:
      en: Stop mode
      zh-cn: Stop mode
    Description:
      en: <p>The stop mode for pay-as-you-go ECS instances. Value:</p> <ul> <li><code="">StopCharging</code=""></li></ul>
      zh-cn: <p>The stop mode for pay-as-you-go ECS instances. Value:</p> <ul> <li><code="">StopCharging</code=""></li></ul>

pour prendre effet. Pour plus d'informations, consultez Mode économique pour les instances à la demande.

Mode d'arrêt standard : l'instance continue d'être facturée après son arrêt.

Le mode d'arrêt des instances à la demande. Valeurs possibles :

  • Mode économique : pour connaître les conditions requises pour activer StopCharging, reportez-vous à la section Conditions dans Mode économique pour les instances à la demande.

  • Mode d'arrêt standard : la facturation se poursuit après l'arrêt de l'instance.

FormatVersion: OOS-2019-06-01 Description: en: Starts and then stops, or stops and then starts, Elastic Compute Service (ECS) instances on a schedule. Parameters: regionId: Label: en: Region Description: en: The region where the ECS instances are located. Type: String AssociationProperty: RegionId Default: '{{ ACS::RegionId }}' targets: Label: en: Target Instance Description: en: The ECS instances to operate on. Type: Json AssociationProperty: Targets AssociationPropertyMetadata: ResourceType: ALIYUN::ECS::Instance RegionId: regionId startFirstOrStopFirst: Label: en: Start First or Stop First Description: en: Specifies whether to start the instances first or stop the instances first. Type: String AllowedValues: - StartFirst - StopFirst Default: StartFirst weekdays: Label: en: Weekdays Description: 'en: The days of the week on which to execute the task. You can specify multiple days, separated by commas (,).' Type: String AllowedPattern: '^((([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN),)*([1-7]|MON|TUE|WED|THU|FRI|SAT|SUN)|^\*|^\?)$' Default: 1,2,3,4,5 dailyStartTime: Label: en: Daily Start Time Description: 'en: The time of day to start the instances. Use the HH:mm format. The time is in UTC.' Type: String AllowedPattern: '^([01]?[0-9]|2[0-3]):[0-5][0-9]$' Default: '09:00' dailyStopTime: Label: en: Daily Stop Time Description: 'en: The time of day to stop the instances. Use the HH:mm format. The time is in UTC.' Type: String AllowedPattern: '^([01]?[0-9]|2[0-3]):[0-5][0-9]$' Default: '18:00' triggerEndDate: Label: en: Trigger End Date Description: 'en: The end date of the scheduled task. The time is in UTC.' Type: String AllowedPattern: ^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]Z$ stoppedMode: Label: en: ECS Stopped Mode Description: 'en: The stop mode for the pay-as-you-go instance. Valid values are StopCharging and KeepCharging. StopCharging: Economical mode. For the conditions required for this mode to take effect, see Economical mode for pay-as-you-go instances. KeepCharging: Standard stop mode. The instance continues to be charged after it is stopped.' Type: String AllowedValues: - StopCharging - KeepCharging Default: KeepCharging AssociationPropertyMetadata: LocaleKey: ECSStoppedMode hibernate: Label: en: Hibernate Instance Type: Boolean Default: false rateControl: Label: en: Rate Control Type: Json AssociationProperty: RateControl Default: Mode: Concurrency MaxErrors: 0 Concurrency: 10 OOSAssumeRole: Label: en: OOS Assume Role Type: String Default: AliyunServiceRoleForOOSInstanceScheduler RamRole: '{{ OOSAssumeRole }}' Tasks: - Name: timerTrigger Action: ACS::TimerTrigger Description: en: Triggers a task on a schedule using a cron expression. Properties: Type: cron EndDate: '{{ triggerEndDate }}' Expression: Fn::Join: - ' ' - - '0' - Fn::Select: - 1 - Fn::Split: - ':' - Fn::If: - Fn::Equals: - StartFirst - '{{startFirstOrStopFirst}}' - '{{ dailyStartTime }}' - '{{ dailyStopTime }}' - Fn::Select: - 0 - Fn::Split: - ':' - Fn::If: - Fn::Equals: - StartFirst - '{{startFirstOrStopFirst}}' - '{{ dailyStartTime }}' - '{{ dailyStopTime }}' - '?' - '*' - '{{ weekdays }}' - Name: getInstance Description: en: Retrieves the specified ECS instances. Action: ACS::SelectTargets Properties: ResourceType: ALIYUN::ECS::Instance RegionId: '{{regionId}}' Filters: - '{{ targets }}' Outputs: instanceIds: Type: List ValueSelector: Instances.Instance[].InstanceId - Name: startInstanceFirst Action: ACS::ECS::StartInstance Description: en: Starts the ECS instances first. When: Fn::Equals: - StartFirst - '{{startFirstOrStopFirst}}' OnError: sleepToStopTime Properties: regionId: '{{ regionId }}' instanceId: '{{ ACS::TaskLoopItem }}' Loop: RateControl: '{{ rateControl }}' Items: '{{ getInstance.instanceIds }}' - Name: sleepToStopTime Action: ACS::Sleep Description: en: Pauses the execution until the specified instance stop time. When: Fn::Equals: - StartFirst - '{{startFirstOrStopFirst}}' Properties: Duration: Fn::DurationBetween: - '{{ dailyStartTime }}' - '{{ dailyStopTime }}' - Name: stopInstanceSecond Action: ACS::ECS::StopInstance Description: en: Stops the ECS instances. When: Fn::Equals: - StartFirst - '{{startFirstOrStopFirst}}' Properties: regionId: '{{ regionId }}' instanceId: '{{ ACS::TaskLoopItem }}' stoppedMode: '{{ stoppedMode }}' hibernate: '{{ hibernate }}' Loop: RateControl: '{{ rateControl }}' Items: '{{ getInstance.instanceIds }}' - Name: stopInstanceFirst Action: ACS::ECS::StopInstance Description: en: Stops the ECS instances first. When: Fn::Equals: - StopFirst - '{{startFirstOrStopFirst}}' OnError: sleepToStartTime Properties: regionId: '{{ regionId }}' instanceId: '{{ ACS::TaskLoopItem }}' stoppedMode: '{{ stoppedMode }}' hibernate: '{{ hibernate }}' Loop: RateControl: '{{ rateControl }}' Items: '{{ getInstance.instanceIds }}' - Name: sleepToStartTime Action: ACS::Sleep Description: en: Pauses the execution until the specified instance start time. When: Fn::Equals: - StopFirst - '{{startFirstOrStopFirst}}' Properties: Duration: Fn::DurationBetween: - '{{ dailyStopTime }}' - '{{ dailyStartTime }}' - Name: startInstance Action: ACS::ECS::StartInstance Description: en: Starts the ECS instances. When: Fn::Equals: - StopFirst - '{{startFirstOrStopFirst}}' Properties: regionId: '{{ regionId }}' instanceId: '{{ ACS::TaskLoopItem }}' Loop: RateControl: '{{ rateControl }}' Items: '{{ getInstance.instanceIds }}'