All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Last Updated:Jun 22, 2026

Template name

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted removes a preemptible instance that is about to be released from the backend server list of its associated Server Load Balancer (SLB) instance.

Execute now

Template description

Removes a preemptible instance in the current region from the backend server list of its associated SLB instance before the instance is released.

Template type

Automation

Owner

Alibaba Cloud

Input parameters

Parameter name

Description

Type

Required

Default value

Constraints

OOSAssumeRole

The RAM role assumed by OOS to execute the template.

String

No

""

tags

The tags used to filter instances.

Json

No

[]

Output parameters

Parameter name

Description

Type

instanceId

String

Access policy required to execute this template

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

Details

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted details

Template content

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