-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::AlarmSpotPriceOrDiscountByScalingGroupInstance.yml
134 lines (134 loc) · 4.43 KB
/
ACS::ECS::AlarmSpotPriceOrDiscountByScalingGroupInstance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::AlarmSpotPriceOrDiscountByScalingGroupInstance
name-zh-cn: 监控伸缩组内实例的现价或折扣的阈值
en: Alarm notification when spot instance discount or spot price exceeds threshold in the scaling group existing instances
zh-cn: 监控弹性伸缩组弹出的预付费实例的最新价格与折扣,超出阈值时发出报警通知
Parameters:
regionId:
Description:
en: The ID the region
zh-cn: 地域ID
Type: String
threshold:
Description:
en: 'The discount threshold(example:10 is 1% off, 50 is 50% off)'
zh-cn: 折扣阈值(例:输入10是1折,50为5折)
Type: Number
taskType:
Description:
en: Monitoring threshold task type
zh-cn: 监控阈值的任务类型
Type: String
instanceType:
Description:
en: The instance type
zh-cn: ECS实例类型
Type: String
zoneId:
Description:
en: The ID of zone
zh-cn: 可用区ID
Type: String
Tasks:
- Name: describeSpotPriceHistoryInfos
Action: 'ACS::ExecuteAPI'
Description:
en: Queries the latest discounts on spot instance
zh-cn: 获取预付费实例的最新折扣
Properties:
Service: ECS
API: DescribeSpotPriceHistory
Parameters:
RegionId: '{{ regionId }}'
InstanceType: '{{ instanceType }}'
NetworkType: vpc
ZoneId: '{{ zoneId }}'
Outputs:
discountAndPrice:
Type: Json
ValueSelector: '.SpotPrices.SpotPriceType[-1] | {"realThreshold":(.SpotPrice / .OriginPrice * 100), "spotPrice":.SpotPrice, "originPrice":.OriginPrice, "instanceType":.InstanceType}'
- Name: selectTask
Action: 'ACS::Choice'
Description:
en: Queries the type of task that performs the monitoring threshold
zh-cn: 获取监控阈值的任务类型
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- Discount
- '{{ taskType }}'
NextTask: checkDiscountThreshold
- When:
'Fn::Equals':
- Price
- '{{ taskType }}'
NextTask: checkSpotPriceThreshold
- Name: checkDiscountThreshold
Action: 'ACS::Choice'
Description:
en: Check wether the actual discount exceeds the threshold
zh-cn: 检测实际折扣是否超过阈值
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '.realThreshold >= {{ threshold }}'
- '{{ describeSpotPriceHistoryInfos.discountAndPrice }}'
NextTask: describeSpotPriceHistory
- Name: checkSpotPriceThreshold
Action: 'ACS::Choice'
Description:
en: Check wether the actual price exceeds the threshold
zh-cn: 检测实际价格是否超过阈值
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '.spotPrice >= {{ threshold }}'
- '{{ describeSpotPriceHistoryInfos.discountAndPrice }}'
NextTask: describeSpotPriceHistory
- Name: describeSpotPriceHistory
Action: 'ACS::ExecuteAPI'
Description:
en: Queries the latest discounts or spot price on spot instance
zh-cn: 获取预付费实例的最新折扣与价格
Properties:
Service: ECS
API: DescribeSpotPriceHistory
Parameters:
RegionId: '{{ regionId }}'
InstanceType: '{{ instanceType }}'
NetworkType: vpc
ZoneId: '{{ zoneId }}'
Outputs:
spotPrice:
Type: String
ValueSelector: '.SpotPrices.SpotPriceType[-1].SpotPrice'
instanceType:
Type: String
ValueSelector: '.SpotPrices.SpotPriceType[-1].InstanceType'
zoneId:
Type: String
ValueSelector: '.SpotPrices.SpotPriceType[-1].ZoneId'
actualDiscount:
Type: String
ValueSelector: '.SpotPrices.SpotPriceType[-1] | .SpotPrice / .OriginPrice * 10000 | floor as $num | $num/100'
Outputs:
discountInfo:
Type: Json
Value:
instanceType: '{{ describeSpotPriceHistory.instanceType }}'
zoneId: '{{ describeSpotPriceHistory.zoneId }}'
spotPrice: '{{ describeSpotPriceHistory.spotPrice }}'
actualDiscount: '"{{ describeSpotPriceHistory.actualDiscount }}"'