Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Dernière mise à jour :Aug 11, 2026

Nom du modèle

Le modèle ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted retire une instance préemptible sur le point d'être libérée de la liste des serveurs backend de son équilibreur de charge (SLB) associé.

Exécuter maintenant

Description du modèle

Retire une instance préemptible de la région actuelle de la liste des serveurs backend de son SLB associé avant sa libération.

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

OOSAssumeRole

Rôle RAM assumé par OOS pour exécuter le modèle.

String

Non

""

tags

Tags utilisés pour filtrer les instances.

Json

Non

[]

Paramètres de sortie

Nom du paramètre

Description

Type

instanceId

String

Stratégie d'accès requise pour exécuter ce modèle

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "slb:DescribeLoadBalancers",
                "slb:RemoveBackendServers",
                "slb:SetBackendServers"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Détails

Détails ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Contenu du modèle

FormatVersion: OOS-2019-06-01
Description:
  en: Removes a spot instance in the current region from a Server Load Balancer instance before the spot instance is released.
  zh-cn: Removes a spot instance in the current region from a Server Load Balancer instance before the spot instance is released.
  name-en: ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted
  name-zh-cn: Removes a spot instance that is about to be released from the backend server list of its Server Load Balancer.
  categories:
    - event-trigger
Parameters:
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes
    Type: String
    Default: ''
  tags:
    Type: Json
    Label:
      en: Tags
      zh-cn: The tags of the instance
    AssociationProperty: Tags
    Default: []
RamRole: '{{OOSAssumeRole}}'
Tasks:
  - Name: eventTrigger
    Description:
      en: Monitors the interruption event of a spot instance.
      zh-cn: Monitors the interruption event of a spot instance.
    Action: 'ACS::EventTrigger'
    Properties:
      Tags: '{{ tags }}'
      Product: ECS
      Name:
        - 'Instance:PreemptibleInstanceInterruption'
      Level:
        - WARN
      Content:
        action: delete
      RegionId:
        - '{{ ACS::RegionId }}'
    Outputs:
      instanceId:
        ValueSelector: .content.instanceId
        Type: String
  - Name: describeSLB
    Description:
      en: Queries the ID of the Server Load Balancer instance associated with the interrupted spot instance.
      zh-cn: Queries the ID of the Server Load Balancer instance associated with the interrupted spot instance.
    Action: 'ACS::ExecuteAPI'
    Properties:
      Service: SLB
      API: DescribeLoadBalancers
      Parameters:
        ServerId: '{{ eventTrigger.instanceId }}'
    Outputs:
      loadBalancerId:
        ValueSelector: .LoadBalancers.LoadBalancer[0].LoadBalancerId
        Type: String
  - Name: setBackendServers
    Description:
      en: Sets the weight of the interrupted instance to 0 on the Server Load Balancer instance.
      zh-cn: Sets the weight of the interrupted instance to 0 on the Server Load Balancer instance.
    Action: 'ACS::ExecuteAPI'
    Properties:
      Service: SLB
      API: SetBackendServers
      Parameters:
        BackendServers:
          - ServerId: '{{ eventTrigger.instanceId }}'
            Weight: 0
        LoadBalancerId: '{{describeSLB.loadBalancerId}}'
  - Name: waitConnectionExpire
    Description:
      en: Waits for existing network connections to close.
      zh-cn: Waits for existing network connections to close.
    Action: 'ACS::Sleep'
    Properties:
      Duration: 'PT1M'
  - Name: removeBackendServers
    Description:
      en: Removes the interrupted instance from the backend server list of the Server Load Balancer instance.
      zh-cn: Removes the interrupted instance from the backend server list of the Server Load Balancer instance.
    Action: 'ACS::ExecuteAPI'
    Properties:
      Service: SLB
      API: RemoveBackendServers
      Parameters:
        BackendServers:
          - ServerId: '{{ eventTrigger.instanceId }}'
            Weight: 0
        LoadBalancerId: '{{describeSLB.loadBalancerId}}'
Outputs:
  instanceId:
    Value: '{{ eventTrigger.instanceId }}'
    Type: String
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - tags
        Label:
          default:
            zh-cn: Select Tags
            en: Select Tags
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Control Options
            en: Control Options