すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

最終更新日:Jun 23, 2026

テンプレート名

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted は、関連付けられた Server Load Balancer (SLB) インスタンスのバックエンドサーバーリストから、リリース予定のプリエンプティブルインスタンスを削除します。

今すぐ実行

テンプレートの説明

現在のリージョンにあるプリエンプティブルインスタンスを、リリースされる前に、関連付けられた SLB インスタンスのバックエンドサーバーリストから削除します。

テンプレートのタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター名

説明

タイプ

必須

デフォルト値

制約

OOSAssumeRole

OOS がテンプレートを実行するために引き受ける RAM ロール。

String

いいえ

""

tags

インスタンスのフィルタリングに使用されるタグ。

Json

いいえ

[]

出力パラメーター

パラメーター名

説明

タイプ

instanceId

String

テンプレート実行に必要なアクセスポリシー

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

詳細

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted の詳細

テンプレートの内容

FormatVersion: OOS-2019-06-01
Description:
  en: Removes a preemptible instance from the Server Load Balancer instance before it is released in the current region.
  zh-cn: 在当前地域,将因中断即将被释放的抢占式实例从其关联的负载均衡实例中移除。
  name-en: ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted
  name-zh-cn: 将即将释放的抢占式实例移出负载均衡
  categories:
    - event-trigger
Parameters:
  OOSAssumeRole:
    Label:
      en: The RAM role to be assumed by OOS to execute the template.
      zh-cn: OOS执行任务时需要扮演的RAM角色。
    Type: String
    Default: ''
  tags:
    Type: Json
    Label:
      en: The tags used to filter instances.
      zh-cn: 用于筛选实例的标签。
    AssociationProperty: Tags
    Default: []
RamRole: '{{OOSAssumeRole}}'
Tasks:
  - Name: eventTrigger
    Description:
      en: Monitors interruption events of preemptible instances.
      zh-cn: 监听抢占式实例的中断事件。
    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 IDs of Server Load Balancer instances that are associated with the interrupted preemptible instance.
      zh-cn: 查询与被中断的抢占式实例关联的负载均衡实例ID。
    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: 在负载均衡实例上将被中断实例的权重设置为0。
    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: 等待存量网络连接关闭。
    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: 从负载均衡实例的后端服务器列表中移除被中断的实例。
    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: 选择标签
            en: Select Tags
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Advanced Options