All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Last Updated:Jun 23, 2026

Nama templat

Templat ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted menghapus instans preemptible yang akan segera dirilis dari daftar server backend pada instance Server Load Balancer (SLB) terkait.

Execute now

Deskripsi templat

Templat ini menghapus instans preemptible di wilayah saat ini dari daftar server backend pada instance SLB terkait sebelum instans tersebut dirilis.

Jenis templat

Automation

Pemilik

Alibaba Cloud

Parameter input

Nama parameter

Deskripsi

Tipe

Wajib

Nilai default

Batasan

OOSAssumeRole

Peran RAM yang diasumsikan oleh OOS untuk mengeksekusi templat.

String

No

""

tags

Tag yang digunakan untuk memfilter instans.

Json

No

[]

Parameter output

Nama parameter

Deskripsi

Type

instanceId

String

Kebijakan akses yang diperlukan untuk mengeksekusi templat ini

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

Detail

Detail ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Konten templat

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