全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

更新时间:Jun 28, 2025

Nama template

ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted

Eksekusi Sekarang

Deskripsi template

Menghapus instance preemptible yang akan dilepaskan dari daftar server backend Server Load Balancer (SLB).

Tipe template

Otomatis

Pemilik

Alibaba Cloud

Parameter input

Parameter

Deskripsi

Tipe

Diperlukan

Nilai default

Batasan

OOSAssumeRole

Peran Resource Access Management (RAM) yang diasumsikan oleh CloudOps Orchestration Service (OOS).

String

Tidak

""

tags

Tag dari instance preemptible.

Json

Tidak

[]

Parameter output

Parameter

Deskripsi

Tipe

instanceId

String

Kebijakan izin yang diperlukan untuk mengeksekusi template

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

Referensi

Untuk informasi lebih lanjut, lihat ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted.yml di GitHub.

Konten Template

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: the description in Chinese
  name-en: ACS-ECS-RemoveFromSLBWhenPreemptibleInstanceInterrupted
  name-zh-cn: the description in Chinese
  categories:
    - event-trigger
Parameters:
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
  tags:
    Type: Json
    Label:
      en: Tags
      zh-cn: the description in Chinese
    AssociationProperty: Tags
    Default: []
RamRole: '{{OOSAssumeRole}}'
Tasks:
  - Name: eventTrigger
    Description:
      en: Monitor the preemptible instance interruption event
      zh-cn: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    Action: 'ACS::Sleep'
    Properties:
      Duration: 'PT1M'
  - Name: removeBackendServers
    Description:
      en: Remove the interrupted instance from SLB backend servers list
      zh-cn: the description in Chinese
    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: the description in Chinese
            en: Select Tags
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options