Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-ScheduleToStopInstances

Dernière mise à jour :Aug 11, 2026

Nom du modèle

ACS-ECS-ScheduleToStopInstances : arrêter les instances ECS selon une planification

Exécuter maintenant

Description du modèle

Arrêtez les instances Elastic Compute Service (ECS) selon une planification définie. Utilisez ce modèle pour éteindre automatiquement vos environnements de développement ou de test afin de réduire les coûts. Spécifiez l'ID de la région, l'expression cron et les instances cibles. Le modèle arrête alors les instances spécifiées en respectant le calendrier configuré.

Type de modèle

Automatisation

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Nom du paramètre

Description

Type

Obligatoire

Valeur par défaut

Contraintes

endDate

Date de fin du déclencheur temporel.

String

Oui

targets

Instances cibles.

Json

Oui

regionId

ID de la région.

String

Non

{{ ACS::RegionId }}

cron

Expression cron.

String

Non

0 0 12 ? * *

timeZone

Fuseau horaire.

String

Non

UTC

rateControl

Taux de concurrence pour l'exécution des tâches.

Json

Non

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

OOSAssumeRole

Rôle RAM endossé par Operation Orchestration Service (OOS).

String

Non

OOSServiceRole

Paramètres de sortie

Nom du paramètre

Description

Type

instanceIds

List

Autorisations requises

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

Détails

Pour plus d'informations, consultez les détails du modèle ACS-ECS-ScheduleToStopInstances.

Contenu du modèle

FormatVersion: OOS-2019-06-01
Description:
  en: 'Schedule to stop the ECS instances, applicable to scenarios where ECS instances need to be stopped at scheduled times, such as automatically stopping development or test environments to save costs. 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, Cron Expression (cron), which defines the schedule for the task, and Target Instances (targets), which defines the specific ECS instances to be operated on. Upon execution, the template will stop the ECS instances according to the configured schedule.'
  name-en: ACS-ECS-ScheduleToStopInstances
  categories:
    - time_trigger
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  cron:
    Description:
      en: 'For more information, see https://www.alibabacloud.com/help/document_detail/169784.html'
    Label:
      en: CronExpression
    Type: String
    AssociationProperty: Cron
    Default: 0 0 12 ? * *
  endDate:
    Description:
      en: 'Format: yyyy-MM-ddTHH:mm:ssZ.'
    Label:
      en: EndDate
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: 'YYYY-MM-DDTHH:mm:ssZ'
  timeZone:
    Label:
      en: TimeZone
    Type: String
    AssociationProperty: TimeZone
    Default: UTC
  targets:
    Type: Json
    Label:
      en: TargetInstance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  rateControl:
    Label:
      en: RateControl
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
  Action: ACS::TimerTrigger
  Description:
    en: Triggers a task as scheduled by specifying type and expression
  Properties:
    Type: cron
    Expression: '{{ cron }}'
    EndDate: '{{ endDate }}'
    TimeZone: '{{ timeZone }}'
- Name: getInstance
  Description:
    en: Views the 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
  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:
            en: Timer Trigger Configure
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            en: Select ECS Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            en: Control Options