全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

更新時間:Sep 06, 2024

模板名稱

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted 將即將釋放的搶佔式執行個體從其所在負載平衡後端伺服器列表移除

立即執行

模板描述

當前地區的搶佔式執行個體即將釋放時,將執行個體從其所在負載平衡後端伺服器列表移除

模板類型

自動化

所有者

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: Remove backend servers from SLB when preemptible instance of current region is about to be interrupted
  zh-cn: 當前地區的搶佔式執行個體即將釋放時,將執行個體從其所在負載平衡後端伺服器列表移除
  name-en: ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted
  name-zh-cn: 將即將釋放的搶佔式執行個體從其所在負載平衡後端伺服器列表移除
  categories:
    - event-trigger
Parameters:
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
  tags:
    Type: Json
    Label:
      en: Tags
      zh-cn: 執行個體的標籤
    AssociationProperty: Tags
    Default: []
RamRole: '{{OOSAssumeRole}}'
Tasks:
  - Name: eventTrigger
    Description:
      en: Monitor the preemptible instance interruption event
      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: Views the SLB id of preemptible instance interrupted
      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: Set the weight of interrupted instance zero on SLB
      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: Wait created connection expire
      zh-cn: 等待已經建立的網路連接斷開
    Action: 'ACS::Sleep'
    Properties:
      Duration: 'PT1M'
  - Name: removeBackendServers
    Description:
      en: Remove the interrupted instance from SLB backend servers list
      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: Control Options