模板名稱
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
文檔內容是否對您有幫助?