/
alarm.go
418 lines (358 loc) · 18.8 KB
/
alarm.go
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package ess
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// ## Import
//
// Ess alarm can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:ess/alarm:Alarm example asg-2ze500_045efffe-4d05
// ```
type Alarm struct {
pulumi.CustomResourceState
// The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
AlarmActions pulumi.StringArrayOutput `pulumi:"alarmActions"`
// Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
CloudMonitorGroupId pulumi.IntPtrOutput `pulumi:"cloudMonitorGroupId"`
// The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
ComparisonOperator pulumi.StringPtrOutput `pulumi:"comparisonOperator"`
// The description for the alarm.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The dimension map for the alarm's associated metric (documented below). For all metrics, you can not set the dimension key as "scalingGroup" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users.
Dimensions pulumi.MapOutput `pulumi:"dimensions"`
// Whether to enable specific ess alarm. Default to true.
Enable pulumi.BoolPtrOutput `pulumi:"enable"`
// The number of times that needs to satisfies comparison condition before transition into ALARM state. Defaults to 3.
EvaluationCount pulumi.IntPtrOutput `pulumi:"evaluationCount"`
// The name for the alarm's associated metric. See Block_metricNames_and_dimensions below for details.
MetricName pulumi.StringOutput `pulumi:"metricName"`
// The type for the alarm's associated metric. Supported value: system, custom. "system" means the metric data is collected by Aliyun Cloud Monitor Service(CMS), "custom" means the metric data is upload to CMS by users. Defaults to system.
MetricType pulumi.StringPtrOutput `pulumi:"metricType"`
// The name for ess alarm.
Name pulumi.StringOutput `pulumi:"name"`
// The period in seconds over which the specified statistic is applied. Supported value: 60, 120, 300, 900. Defaults to 300.
Period pulumi.IntPtrOutput `pulumi:"period"`
// The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+.
ScalingGroupId pulumi.StringOutput `pulumi:"scalingGroupId"`
// The state of specified alarm.
State pulumi.StringOutput `pulumi:"state"`
// The statistic to apply to the alarm's associated metric. Supported value: Average, Minimum, Maximum. Defaults to Average.
Statistics pulumi.StringPtrOutput `pulumi:"statistics"`
// The value against which the specified statistics is compared.
Threshold pulumi.StringOutput `pulumi:"threshold"`
}
// NewAlarm registers a new resource with the given unique name, arguments, and options.
func NewAlarm(ctx *pulumi.Context,
name string, args *AlarmArgs, opts ...pulumi.ResourceOption) (*Alarm, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AlarmActions == nil {
return nil, errors.New("invalid value for required argument 'AlarmActions'")
}
if args.MetricName == nil {
return nil, errors.New("invalid value for required argument 'MetricName'")
}
if args.ScalingGroupId == nil {
return nil, errors.New("invalid value for required argument 'ScalingGroupId'")
}
if args.Threshold == nil {
return nil, errors.New("invalid value for required argument 'Threshold'")
}
var resource Alarm
err := ctx.RegisterResource("alicloud:ess/alarm:Alarm", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetAlarm gets an existing Alarm resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetAlarm(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *AlarmState, opts ...pulumi.ResourceOption) (*Alarm, error) {
var resource Alarm
err := ctx.ReadResource("alicloud:ess/alarm:Alarm", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Alarm resources.
type alarmState struct {
// The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
AlarmActions []string `pulumi:"alarmActions"`
// Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
CloudMonitorGroupId *int `pulumi:"cloudMonitorGroupId"`
// The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
ComparisonOperator *string `pulumi:"comparisonOperator"`
// The description for the alarm.
Description *string `pulumi:"description"`
// The dimension map for the alarm's associated metric (documented below). For all metrics, you can not set the dimension key as "scalingGroup" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users.
Dimensions map[string]interface{} `pulumi:"dimensions"`
// Whether to enable specific ess alarm. Default to true.
Enable *bool `pulumi:"enable"`
// The number of times that needs to satisfies comparison condition before transition into ALARM state. Defaults to 3.
EvaluationCount *int `pulumi:"evaluationCount"`
// The name for the alarm's associated metric. See Block_metricNames_and_dimensions below for details.
MetricName *string `pulumi:"metricName"`
// The type for the alarm's associated metric. Supported value: system, custom. "system" means the metric data is collected by Aliyun Cloud Monitor Service(CMS), "custom" means the metric data is upload to CMS by users. Defaults to system.
MetricType *string `pulumi:"metricType"`
// The name for ess alarm.
Name *string `pulumi:"name"`
// The period in seconds over which the specified statistic is applied. Supported value: 60, 120, 300, 900. Defaults to 300.
Period *int `pulumi:"period"`
// The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+.
ScalingGroupId *string `pulumi:"scalingGroupId"`
// The state of specified alarm.
State *string `pulumi:"state"`
// The statistic to apply to the alarm's associated metric. Supported value: Average, Minimum, Maximum. Defaults to Average.
Statistics *string `pulumi:"statistics"`
// The value against which the specified statistics is compared.
Threshold *string `pulumi:"threshold"`
}
type AlarmState struct {
// The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
AlarmActions pulumi.StringArrayInput
// Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
CloudMonitorGroupId pulumi.IntPtrInput
// The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
ComparisonOperator pulumi.StringPtrInput
// The description for the alarm.
Description pulumi.StringPtrInput
// The dimension map for the alarm's associated metric (documented below). For all metrics, you can not set the dimension key as "scalingGroup" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users.
Dimensions pulumi.MapInput
// Whether to enable specific ess alarm. Default to true.
Enable pulumi.BoolPtrInput
// The number of times that needs to satisfies comparison condition before transition into ALARM state. Defaults to 3.
EvaluationCount pulumi.IntPtrInput
// The name for the alarm's associated metric. See Block_metricNames_and_dimensions below for details.
MetricName pulumi.StringPtrInput
// The type for the alarm's associated metric. Supported value: system, custom. "system" means the metric data is collected by Aliyun Cloud Monitor Service(CMS), "custom" means the metric data is upload to CMS by users. Defaults to system.
MetricType pulumi.StringPtrInput
// The name for ess alarm.
Name pulumi.StringPtrInput
// The period in seconds over which the specified statistic is applied. Supported value: 60, 120, 300, 900. Defaults to 300.
Period pulumi.IntPtrInput
// The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+.
ScalingGroupId pulumi.StringPtrInput
// The state of specified alarm.
State pulumi.StringPtrInput
// The statistic to apply to the alarm's associated metric. Supported value: Average, Minimum, Maximum. Defaults to Average.
Statistics pulumi.StringPtrInput
// The value against which the specified statistics is compared.
Threshold pulumi.StringPtrInput
}
func (AlarmState) ElementType() reflect.Type {
return reflect.TypeOf((*alarmState)(nil)).Elem()
}
type alarmArgs struct {
// The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
AlarmActions []string `pulumi:"alarmActions"`
// Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
CloudMonitorGroupId *int `pulumi:"cloudMonitorGroupId"`
// The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
ComparisonOperator *string `pulumi:"comparisonOperator"`
// The description for the alarm.
Description *string `pulumi:"description"`
// The dimension map for the alarm's associated metric (documented below). For all metrics, you can not set the dimension key as "scalingGroup" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users.
Dimensions map[string]interface{} `pulumi:"dimensions"`
// Whether to enable specific ess alarm. Default to true.
Enable *bool `pulumi:"enable"`
// The number of times that needs to satisfies comparison condition before transition into ALARM state. Defaults to 3.
EvaluationCount *int `pulumi:"evaluationCount"`
// The name for the alarm's associated metric. See Block_metricNames_and_dimensions below for details.
MetricName string `pulumi:"metricName"`
// The type for the alarm's associated metric. Supported value: system, custom. "system" means the metric data is collected by Aliyun Cloud Monitor Service(CMS), "custom" means the metric data is upload to CMS by users. Defaults to system.
MetricType *string `pulumi:"metricType"`
// The name for ess alarm.
Name *string `pulumi:"name"`
// The period in seconds over which the specified statistic is applied. Supported value: 60, 120, 300, 900. Defaults to 300.
Period *int `pulumi:"period"`
// The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+.
ScalingGroupId string `pulumi:"scalingGroupId"`
// The statistic to apply to the alarm's associated metric. Supported value: Average, Minimum, Maximum. Defaults to Average.
Statistics *string `pulumi:"statistics"`
// The value against which the specified statistics is compared.
Threshold string `pulumi:"threshold"`
}
// The set of arguments for constructing a Alarm resource.
type AlarmArgs struct {
// The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari.
AlarmActions pulumi.StringArrayInput
// Defines the application group id defined by CMS which is assigned when you upload custom metric to CMS, only available for custom metirc.
CloudMonitorGroupId pulumi.IntPtrInput
// The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Supported value: >=, <=, >, <. Defaults to >=.
ComparisonOperator pulumi.StringPtrInput
// The description for the alarm.
Description pulumi.StringPtrInput
// The dimension map for the alarm's associated metric (documented below). For all metrics, you can not set the dimension key as "scalingGroup" or "userId", which is set by default, the second dimension for metric, such as "device" for "PackagesNetIn", need to be set by users.
Dimensions pulumi.MapInput
// Whether to enable specific ess alarm. Default to true.
Enable pulumi.BoolPtrInput
// The number of times that needs to satisfies comparison condition before transition into ALARM state. Defaults to 3.
EvaluationCount pulumi.IntPtrInput
// The name for the alarm's associated metric. See Block_metricNames_and_dimensions below for details.
MetricName pulumi.StringInput
// The type for the alarm's associated metric. Supported value: system, custom. "system" means the metric data is collected by Aliyun Cloud Monitor Service(CMS), "custom" means the metric data is upload to CMS by users. Defaults to system.
MetricType pulumi.StringPtrInput
// The name for ess alarm.
Name pulumi.StringPtrInput
// The period in seconds over which the specified statistic is applied. Supported value: 60, 120, 300, 900. Defaults to 300.
Period pulumi.IntPtrInput
// The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+.
ScalingGroupId pulumi.StringInput
// The statistic to apply to the alarm's associated metric. Supported value: Average, Minimum, Maximum. Defaults to Average.
Statistics pulumi.StringPtrInput
// The value against which the specified statistics is compared.
Threshold pulumi.StringInput
}
func (AlarmArgs) ElementType() reflect.Type {
return reflect.TypeOf((*alarmArgs)(nil)).Elem()
}
type AlarmInput interface {
pulumi.Input
ToAlarmOutput() AlarmOutput
ToAlarmOutputWithContext(ctx context.Context) AlarmOutput
}
func (*Alarm) ElementType() reflect.Type {
return reflect.TypeOf((*Alarm)(nil))
}
func (i *Alarm) ToAlarmOutput() AlarmOutput {
return i.ToAlarmOutputWithContext(context.Background())
}
func (i *Alarm) ToAlarmOutputWithContext(ctx context.Context) AlarmOutput {
return pulumi.ToOutputWithContext(ctx, i).(AlarmOutput)
}
func (i *Alarm) ToAlarmPtrOutput() AlarmPtrOutput {
return i.ToAlarmPtrOutputWithContext(context.Background())
}
func (i *Alarm) ToAlarmPtrOutputWithContext(ctx context.Context) AlarmPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(AlarmPtrOutput)
}
type AlarmPtrInput interface {
pulumi.Input
ToAlarmPtrOutput() AlarmPtrOutput
ToAlarmPtrOutputWithContext(ctx context.Context) AlarmPtrOutput
}
type alarmPtrType AlarmArgs
func (*alarmPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Alarm)(nil))
}
func (i *alarmPtrType) ToAlarmPtrOutput() AlarmPtrOutput {
return i.ToAlarmPtrOutputWithContext(context.Background())
}
func (i *alarmPtrType) ToAlarmPtrOutputWithContext(ctx context.Context) AlarmPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(AlarmPtrOutput)
}
// AlarmArrayInput is an input type that accepts AlarmArray and AlarmArrayOutput values.
// You can construct a concrete instance of `AlarmArrayInput` via:
//
// AlarmArray{ AlarmArgs{...} }
type AlarmArrayInput interface {
pulumi.Input
ToAlarmArrayOutput() AlarmArrayOutput
ToAlarmArrayOutputWithContext(context.Context) AlarmArrayOutput
}
type AlarmArray []AlarmInput
func (AlarmArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*Alarm)(nil))
}
func (i AlarmArray) ToAlarmArrayOutput() AlarmArrayOutput {
return i.ToAlarmArrayOutputWithContext(context.Background())
}
func (i AlarmArray) ToAlarmArrayOutputWithContext(ctx context.Context) AlarmArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(AlarmArrayOutput)
}
// AlarmMapInput is an input type that accepts AlarmMap and AlarmMapOutput values.
// You can construct a concrete instance of `AlarmMapInput` via:
//
// AlarmMap{ "key": AlarmArgs{...} }
type AlarmMapInput interface {
pulumi.Input
ToAlarmMapOutput() AlarmMapOutput
ToAlarmMapOutputWithContext(context.Context) AlarmMapOutput
}
type AlarmMap map[string]AlarmInput
func (AlarmMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*Alarm)(nil))
}
func (i AlarmMap) ToAlarmMapOutput() AlarmMapOutput {
return i.ToAlarmMapOutputWithContext(context.Background())
}
func (i AlarmMap) ToAlarmMapOutputWithContext(ctx context.Context) AlarmMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(AlarmMapOutput)
}
type AlarmOutput struct {
*pulumi.OutputState
}
func (AlarmOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Alarm)(nil))
}
func (o AlarmOutput) ToAlarmOutput() AlarmOutput {
return o
}
func (o AlarmOutput) ToAlarmOutputWithContext(ctx context.Context) AlarmOutput {
return o
}
func (o AlarmOutput) ToAlarmPtrOutput() AlarmPtrOutput {
return o.ToAlarmPtrOutputWithContext(context.Background())
}
func (o AlarmOutput) ToAlarmPtrOutputWithContext(ctx context.Context) AlarmPtrOutput {
return o.ApplyT(func(v Alarm) *Alarm {
return &v
}).(AlarmPtrOutput)
}
type AlarmPtrOutput struct {
*pulumi.OutputState
}
func (AlarmPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Alarm)(nil))
}
func (o AlarmPtrOutput) ToAlarmPtrOutput() AlarmPtrOutput {
return o
}
func (o AlarmPtrOutput) ToAlarmPtrOutputWithContext(ctx context.Context) AlarmPtrOutput {
return o
}
type AlarmArrayOutput struct{ *pulumi.OutputState }
func (AlarmArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Alarm)(nil))
}
func (o AlarmArrayOutput) ToAlarmArrayOutput() AlarmArrayOutput {
return o
}
func (o AlarmArrayOutput) ToAlarmArrayOutputWithContext(ctx context.Context) AlarmArrayOutput {
return o
}
func (o AlarmArrayOutput) Index(i pulumi.IntInput) AlarmOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Alarm {
return vs[0].([]Alarm)[vs[1].(int)]
}).(AlarmOutput)
}
type AlarmMapOutput struct{ *pulumi.OutputState }
func (AlarmMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Alarm)(nil))
}
func (o AlarmMapOutput) ToAlarmMapOutput() AlarmMapOutput {
return o
}
func (o AlarmMapOutput) ToAlarmMapOutputWithContext(ctx context.Context) AlarmMapOutput {
return o
}
func (o AlarmMapOutput) MapIndex(k pulumi.StringInput) AlarmOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Alarm {
return vs[0].(map[string]Alarm)[vs[1].(string)]
}).(AlarmOutput)
}
func init() {
pulumi.RegisterOutputType(AlarmOutput{})
pulumi.RegisterOutputType(AlarmPtrOutput{})
pulumi.RegisterOutputType(AlarmArrayOutput{})
pulumi.RegisterOutputType(AlarmMapOutput{})
}