/
scalingRule.go
406 lines (346 loc) · 19.7 KB
/
scalingRule.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
// *** 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 scaling rule can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:ess/scalingRule:ScalingRule example abc123456
// ```
type ScalingRule struct {
pulumi.CustomResourceState
// Adjustment mode of a scaling rule. Optional values:
// - QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
// - PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
// - TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentType pulumi.StringPtrOutput `pulumi:"adjustmentType"`
// The number of ECS instances to be adjusted in the scaling rule. This parameter is required and applicable only to simple scaling rules. The number of ECS instances to be adjusted in a single scaling activity cannot exceed 500. Value range:
// - QuantityChangeInCapacity:(0, 500] U (-500, 0]
// - PercentChangeInCapacity:[0, 10000] U [-100, 0]
// - TotalCapacity:[0, 1000]
AdjustmentValue pulumi.IntPtrOutput `pulumi:"adjustmentValue"`
Ari pulumi.StringOutput `pulumi:"ari"`
// The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Value range: [0, 86,400], in seconds. The default value is empty,if not set, the return value will be 0, which is the default value of integer.
Cooldown pulumi.IntPtrOutput `pulumi:"cooldown"`
// Indicates whether scale in by the target tracking policy is disabled. Default to false.
DisableScaleIn pulumi.BoolPtrOutput `pulumi:"disableScaleIn"`
// The estimated time, in seconds, until a newly launched instance will contribute CloudMonitor metrics. Default to 300.
EstimatedInstanceWarmup pulumi.IntOutput `pulumi:"estimatedInstanceWarmup"`
// A CloudMonitor metric name.
MetricName pulumi.StringPtrOutput `pulumi:"metricName"`
// ID of the scaling group of a scaling rule.
ScalingGroupId pulumi.StringOutput `pulumi:"scalingGroupId"`
// Name shown for the scaling rule, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain number, underscores `_`, hypens `-`, and decimal point `.`. If this parameter value is not specified, the default value is scaling rule id.
ScalingRuleName pulumi.StringOutput `pulumi:"scalingRuleName"`
// The scaling rule type, either "SimpleScalingRule", "TargetTrackingScalingRule", "StepScalingRule". Default to "SimpleScalingRule".
ScalingRuleType pulumi.StringPtrOutput `pulumi:"scalingRuleType"`
// Steps for StepScalingRule. See Block stepAdjustment below for details.
StepAdjustments ScalingRuleStepAdjustmentArrayOutput `pulumi:"stepAdjustments"`
// The target value for the metric.
TargetValue pulumi.Float64PtrOutput `pulumi:"targetValue"`
}
// NewScalingRule registers a new resource with the given unique name, arguments, and options.
func NewScalingRule(ctx *pulumi.Context,
name string, args *ScalingRuleArgs, opts ...pulumi.ResourceOption) (*ScalingRule, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ScalingGroupId == nil {
return nil, errors.New("invalid value for required argument 'ScalingGroupId'")
}
var resource ScalingRule
err := ctx.RegisterResource("alicloud:ess/scalingRule:ScalingRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetScalingRule gets an existing ScalingRule 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 GetScalingRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ScalingRuleState, opts ...pulumi.ResourceOption) (*ScalingRule, error) {
var resource ScalingRule
err := ctx.ReadResource("alicloud:ess/scalingRule:ScalingRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ScalingRule resources.
type scalingRuleState struct {
// Adjustment mode of a scaling rule. Optional values:
// - QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
// - PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
// - TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentType *string `pulumi:"adjustmentType"`
// The number of ECS instances to be adjusted in the scaling rule. This parameter is required and applicable only to simple scaling rules. The number of ECS instances to be adjusted in a single scaling activity cannot exceed 500. Value range:
// - QuantityChangeInCapacity:(0, 500] U (-500, 0]
// - PercentChangeInCapacity:[0, 10000] U [-100, 0]
// - TotalCapacity:[0, 1000]
AdjustmentValue *int `pulumi:"adjustmentValue"`
Ari *string `pulumi:"ari"`
// The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Value range: [0, 86,400], in seconds. The default value is empty,if not set, the return value will be 0, which is the default value of integer.
Cooldown *int `pulumi:"cooldown"`
// Indicates whether scale in by the target tracking policy is disabled. Default to false.
DisableScaleIn *bool `pulumi:"disableScaleIn"`
// The estimated time, in seconds, until a newly launched instance will contribute CloudMonitor metrics. Default to 300.
EstimatedInstanceWarmup *int `pulumi:"estimatedInstanceWarmup"`
// A CloudMonitor metric name.
MetricName *string `pulumi:"metricName"`
// ID of the scaling group of a scaling rule.
ScalingGroupId *string `pulumi:"scalingGroupId"`
// Name shown for the scaling rule, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain number, underscores `_`, hypens `-`, and decimal point `.`. If this parameter value is not specified, the default value is scaling rule id.
ScalingRuleName *string `pulumi:"scalingRuleName"`
// The scaling rule type, either "SimpleScalingRule", "TargetTrackingScalingRule", "StepScalingRule". Default to "SimpleScalingRule".
ScalingRuleType *string `pulumi:"scalingRuleType"`
// Steps for StepScalingRule. See Block stepAdjustment below for details.
StepAdjustments []ScalingRuleStepAdjustment `pulumi:"stepAdjustments"`
// The target value for the metric.
TargetValue *float64 `pulumi:"targetValue"`
}
type ScalingRuleState struct {
// Adjustment mode of a scaling rule. Optional values:
// - QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
// - PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
// - TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentType pulumi.StringPtrInput
// The number of ECS instances to be adjusted in the scaling rule. This parameter is required and applicable only to simple scaling rules. The number of ECS instances to be adjusted in a single scaling activity cannot exceed 500. Value range:
// - QuantityChangeInCapacity:(0, 500] U (-500, 0]
// - PercentChangeInCapacity:[0, 10000] U [-100, 0]
// - TotalCapacity:[0, 1000]
AdjustmentValue pulumi.IntPtrInput
Ari pulumi.StringPtrInput
// The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Value range: [0, 86,400], in seconds. The default value is empty,if not set, the return value will be 0, which is the default value of integer.
Cooldown pulumi.IntPtrInput
// Indicates whether scale in by the target tracking policy is disabled. Default to false.
DisableScaleIn pulumi.BoolPtrInput
// The estimated time, in seconds, until a newly launched instance will contribute CloudMonitor metrics. Default to 300.
EstimatedInstanceWarmup pulumi.IntPtrInput
// A CloudMonitor metric name.
MetricName pulumi.StringPtrInput
// ID of the scaling group of a scaling rule.
ScalingGroupId pulumi.StringPtrInput
// Name shown for the scaling rule, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain number, underscores `_`, hypens `-`, and decimal point `.`. If this parameter value is not specified, the default value is scaling rule id.
ScalingRuleName pulumi.StringPtrInput
// The scaling rule type, either "SimpleScalingRule", "TargetTrackingScalingRule", "StepScalingRule". Default to "SimpleScalingRule".
ScalingRuleType pulumi.StringPtrInput
// Steps for StepScalingRule. See Block stepAdjustment below for details.
StepAdjustments ScalingRuleStepAdjustmentArrayInput
// The target value for the metric.
TargetValue pulumi.Float64PtrInput
}
func (ScalingRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*scalingRuleState)(nil)).Elem()
}
type scalingRuleArgs struct {
// Adjustment mode of a scaling rule. Optional values:
// - QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
// - PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
// - TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentType *string `pulumi:"adjustmentType"`
// The number of ECS instances to be adjusted in the scaling rule. This parameter is required and applicable only to simple scaling rules. The number of ECS instances to be adjusted in a single scaling activity cannot exceed 500. Value range:
// - QuantityChangeInCapacity:(0, 500] U (-500, 0]
// - PercentChangeInCapacity:[0, 10000] U [-100, 0]
// - TotalCapacity:[0, 1000]
AdjustmentValue *int `pulumi:"adjustmentValue"`
// The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Value range: [0, 86,400], in seconds. The default value is empty,if not set, the return value will be 0, which is the default value of integer.
Cooldown *int `pulumi:"cooldown"`
// Indicates whether scale in by the target tracking policy is disabled. Default to false.
DisableScaleIn *bool `pulumi:"disableScaleIn"`
// The estimated time, in seconds, until a newly launched instance will contribute CloudMonitor metrics. Default to 300.
EstimatedInstanceWarmup *int `pulumi:"estimatedInstanceWarmup"`
// A CloudMonitor metric name.
MetricName *string `pulumi:"metricName"`
// ID of the scaling group of a scaling rule.
ScalingGroupId string `pulumi:"scalingGroupId"`
// Name shown for the scaling rule, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain number, underscores `_`, hypens `-`, and decimal point `.`. If this parameter value is not specified, the default value is scaling rule id.
ScalingRuleName *string `pulumi:"scalingRuleName"`
// The scaling rule type, either "SimpleScalingRule", "TargetTrackingScalingRule", "StepScalingRule". Default to "SimpleScalingRule".
ScalingRuleType *string `pulumi:"scalingRuleType"`
// Steps for StepScalingRule. See Block stepAdjustment below for details.
StepAdjustments []ScalingRuleStepAdjustment `pulumi:"stepAdjustments"`
// The target value for the metric.
TargetValue *float64 `pulumi:"targetValue"`
}
// The set of arguments for constructing a ScalingRule resource.
type ScalingRuleArgs struct {
// Adjustment mode of a scaling rule. Optional values:
// - QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
// - PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
// - TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentType pulumi.StringPtrInput
// The number of ECS instances to be adjusted in the scaling rule. This parameter is required and applicable only to simple scaling rules. The number of ECS instances to be adjusted in a single scaling activity cannot exceed 500. Value range:
// - QuantityChangeInCapacity:(0, 500] U (-500, 0]
// - PercentChangeInCapacity:[0, 10000] U [-100, 0]
// - TotalCapacity:[0, 1000]
AdjustmentValue pulumi.IntPtrInput
// The cooldown time of the scaling rule. This parameter is applicable only to simple scaling rules. Value range: [0, 86,400], in seconds. The default value is empty,if not set, the return value will be 0, which is the default value of integer.
Cooldown pulumi.IntPtrInput
// Indicates whether scale in by the target tracking policy is disabled. Default to false.
DisableScaleIn pulumi.BoolPtrInput
// The estimated time, in seconds, until a newly launched instance will contribute CloudMonitor metrics. Default to 300.
EstimatedInstanceWarmup pulumi.IntPtrInput
// A CloudMonitor metric name.
MetricName pulumi.StringPtrInput
// ID of the scaling group of a scaling rule.
ScalingGroupId pulumi.StringInput
// Name shown for the scaling rule, which must contain 2-64 characters (English or Chinese), starting with numbers, English letters or Chinese characters, and can contain number, underscores `_`, hypens `-`, and decimal point `.`. If this parameter value is not specified, the default value is scaling rule id.
ScalingRuleName pulumi.StringPtrInput
// The scaling rule type, either "SimpleScalingRule", "TargetTrackingScalingRule", "StepScalingRule". Default to "SimpleScalingRule".
ScalingRuleType pulumi.StringPtrInput
// Steps for StepScalingRule. See Block stepAdjustment below for details.
StepAdjustments ScalingRuleStepAdjustmentArrayInput
// The target value for the metric.
TargetValue pulumi.Float64PtrInput
}
func (ScalingRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*scalingRuleArgs)(nil)).Elem()
}
type ScalingRuleInput interface {
pulumi.Input
ToScalingRuleOutput() ScalingRuleOutput
ToScalingRuleOutputWithContext(ctx context.Context) ScalingRuleOutput
}
func (*ScalingRule) ElementType() reflect.Type {
return reflect.TypeOf((*ScalingRule)(nil))
}
func (i *ScalingRule) ToScalingRuleOutput() ScalingRuleOutput {
return i.ToScalingRuleOutputWithContext(context.Background())
}
func (i *ScalingRule) ToScalingRuleOutputWithContext(ctx context.Context) ScalingRuleOutput {
return pulumi.ToOutputWithContext(ctx, i).(ScalingRuleOutput)
}
func (i *ScalingRule) ToScalingRulePtrOutput() ScalingRulePtrOutput {
return i.ToScalingRulePtrOutputWithContext(context.Background())
}
func (i *ScalingRule) ToScalingRulePtrOutputWithContext(ctx context.Context) ScalingRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ScalingRulePtrOutput)
}
type ScalingRulePtrInput interface {
pulumi.Input
ToScalingRulePtrOutput() ScalingRulePtrOutput
ToScalingRulePtrOutputWithContext(ctx context.Context) ScalingRulePtrOutput
}
type scalingRulePtrType ScalingRuleArgs
func (*scalingRulePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**ScalingRule)(nil))
}
func (i *scalingRulePtrType) ToScalingRulePtrOutput() ScalingRulePtrOutput {
return i.ToScalingRulePtrOutputWithContext(context.Background())
}
func (i *scalingRulePtrType) ToScalingRulePtrOutputWithContext(ctx context.Context) ScalingRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ScalingRulePtrOutput)
}
// ScalingRuleArrayInput is an input type that accepts ScalingRuleArray and ScalingRuleArrayOutput values.
// You can construct a concrete instance of `ScalingRuleArrayInput` via:
//
// ScalingRuleArray{ ScalingRuleArgs{...} }
type ScalingRuleArrayInput interface {
pulumi.Input
ToScalingRuleArrayOutput() ScalingRuleArrayOutput
ToScalingRuleArrayOutputWithContext(context.Context) ScalingRuleArrayOutput
}
type ScalingRuleArray []ScalingRuleInput
func (ScalingRuleArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*ScalingRule)(nil))
}
func (i ScalingRuleArray) ToScalingRuleArrayOutput() ScalingRuleArrayOutput {
return i.ToScalingRuleArrayOutputWithContext(context.Background())
}
func (i ScalingRuleArray) ToScalingRuleArrayOutputWithContext(ctx context.Context) ScalingRuleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ScalingRuleArrayOutput)
}
// ScalingRuleMapInput is an input type that accepts ScalingRuleMap and ScalingRuleMapOutput values.
// You can construct a concrete instance of `ScalingRuleMapInput` via:
//
// ScalingRuleMap{ "key": ScalingRuleArgs{...} }
type ScalingRuleMapInput interface {
pulumi.Input
ToScalingRuleMapOutput() ScalingRuleMapOutput
ToScalingRuleMapOutputWithContext(context.Context) ScalingRuleMapOutput
}
type ScalingRuleMap map[string]ScalingRuleInput
func (ScalingRuleMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*ScalingRule)(nil))
}
func (i ScalingRuleMap) ToScalingRuleMapOutput() ScalingRuleMapOutput {
return i.ToScalingRuleMapOutputWithContext(context.Background())
}
func (i ScalingRuleMap) ToScalingRuleMapOutputWithContext(ctx context.Context) ScalingRuleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ScalingRuleMapOutput)
}
type ScalingRuleOutput struct {
*pulumi.OutputState
}
func (ScalingRuleOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ScalingRule)(nil))
}
func (o ScalingRuleOutput) ToScalingRuleOutput() ScalingRuleOutput {
return o
}
func (o ScalingRuleOutput) ToScalingRuleOutputWithContext(ctx context.Context) ScalingRuleOutput {
return o
}
func (o ScalingRuleOutput) ToScalingRulePtrOutput() ScalingRulePtrOutput {
return o.ToScalingRulePtrOutputWithContext(context.Background())
}
func (o ScalingRuleOutput) ToScalingRulePtrOutputWithContext(ctx context.Context) ScalingRulePtrOutput {
return o.ApplyT(func(v ScalingRule) *ScalingRule {
return &v
}).(ScalingRulePtrOutput)
}
type ScalingRulePtrOutput struct {
*pulumi.OutputState
}
func (ScalingRulePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ScalingRule)(nil))
}
func (o ScalingRulePtrOutput) ToScalingRulePtrOutput() ScalingRulePtrOutput {
return o
}
func (o ScalingRulePtrOutput) ToScalingRulePtrOutputWithContext(ctx context.Context) ScalingRulePtrOutput {
return o
}
type ScalingRuleArrayOutput struct{ *pulumi.OutputState }
func (ScalingRuleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]ScalingRule)(nil))
}
func (o ScalingRuleArrayOutput) ToScalingRuleArrayOutput() ScalingRuleArrayOutput {
return o
}
func (o ScalingRuleArrayOutput) ToScalingRuleArrayOutputWithContext(ctx context.Context) ScalingRuleArrayOutput {
return o
}
func (o ScalingRuleArrayOutput) Index(i pulumi.IntInput) ScalingRuleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) ScalingRule {
return vs[0].([]ScalingRule)[vs[1].(int)]
}).(ScalingRuleOutput)
}
type ScalingRuleMapOutput struct{ *pulumi.OutputState }
func (ScalingRuleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]ScalingRule)(nil))
}
func (o ScalingRuleMapOutput) ToScalingRuleMapOutput() ScalingRuleMapOutput {
return o
}
func (o ScalingRuleMapOutput) ToScalingRuleMapOutputWithContext(ctx context.Context) ScalingRuleMapOutput {
return o
}
func (o ScalingRuleMapOutput) MapIndex(k pulumi.StringInput) ScalingRuleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) ScalingRule {
return vs[0].(map[string]ScalingRule)[vs[1].(string)]
}).(ScalingRuleOutput)
}
func init() {
pulumi.RegisterOutputType(ScalingRuleOutput{})
pulumi.RegisterOutputType(ScalingRulePtrOutput{})
pulumi.RegisterOutputType(ScalingRuleArrayOutput{})
pulumi.RegisterOutputType(ScalingRuleMapOutput{})
}