/
policy.go
1083 lines (1023 loc) · 43.2 KB
/
policy.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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package autoscaling
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an AutoScaling Scaling Policy resource.
//
// > **NOTE:** You may want to omit `desiredCapacity` attribute from attached `autoscaling.Group`
// when using autoscaling policies. It's good practice to pick either
// [manual](https://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-manual-scaling.html)
// or [dynamic](https://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html)
// (policy-based) scaling.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// bar, err := autoscaling.NewGroup(ctx, "bar", &autoscaling.GroupArgs{
// AvailabilityZones: pulumi.StringArray{
// pulumi.String("us-east-1a"),
// },
// MaxSize: pulumi.Int(5),
// MinSize: pulumi.Int(2),
// HealthCheckGracePeriod: pulumi.Int(300),
// HealthCheckType: pulumi.String("ELB"),
// ForceDelete: pulumi.Bool(true),
// LaunchConfiguration: pulumi.Any(aws_launch_configuration.Foo.Name),
// })
// if err != nil {
// return err
// }
// _, err = autoscaling.NewPolicy(ctx, "bat", &autoscaling.PolicyArgs{
// ScalingAdjustment: pulumi.Int(4),
// AdjustmentType: pulumi.String("ChangeInCapacity"),
// Cooldown: pulumi.Int(300),
// AutoscalingGroupName: bar.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ### Create target tarcking scaling policy using metric math
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// AutoscalingGroupName: pulumi.String("my-test-asg"),
// PolicyType: pulumi.String("TargetTrackingScaling"),
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// CustomizedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationArgs{
// Metrics: autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricArray{
// &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricArgs{
// Id: pulumi.String("m1"),
// Label: pulumi.String("Get the queue size (the number of messages waiting to be processed)"),
// MetricStat: &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatArgs{
// Metric: &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricArgs{
// Dimensions: autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricDimensionArray{
// &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricDimensionArgs{
// Name: pulumi.String("QueueName"),
// Value: pulumi.String("my-queue"),
// },
// },
// MetricName: pulumi.String("ApproximateNumberOfMessagesVisible"),
// Namespace: pulumi.String("AWS/SQS"),
// },
// Stat: pulumi.String("Sum"),
// },
// ReturnData: pulumi.Bool(false),
// },
// &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricArgs{
// Id: pulumi.String("m2"),
// Label: pulumi.String("Get the group size (the number of InService instances)"),
// MetricStat: &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatArgs{
// Metric: &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricArgs{
// Dimensions: autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricDimensionArray{
// &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricMetricStatMetricDimensionArgs{
// Name: pulumi.String("AutoScalingGroupName"),
// Value: pulumi.String("my-asg"),
// },
// },
// MetricName: pulumi.String("GroupInServiceInstances"),
// Namespace: pulumi.String("AWS/AutoScaling"),
// },
// Stat: pulumi.String("Average"),
// },
// ReturnData: pulumi.Bool(false),
// },
// &autoscaling.PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricArgs{
// Expression: pulumi.String("m1 / m2"),
// Id: pulumi.String("e1"),
// Label: pulumi.String("Calculate the backlog per instance"),
// ReturnData: pulumi.Bool(true),
// },
// },
// },
// TargetValue: pulumi.Float64(100),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ### Create predictive scaling policy using customized metrics
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// AutoscalingGroupName: pulumi.String("my-test-asg"),
// PolicyType: pulumi.String("PredictiveScaling"),
// PredictiveScalingConfiguration: &autoscaling.PolicyPredictiveScalingConfigurationArgs{
// MetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationArgs{
// CustomizedCapacityMetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedCapacityMetricSpecificationArgs{
// MetricDataQueries: autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedCapacityMetricSpecificationMetricDataQueryArray{
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedCapacityMetricSpecificationMetricDataQueryArgs{
// Expression: pulumi.String("SUM(SEARCH('{AWS/AutoScaling,AutoScalingGroupName} MetricName=\"GroupInServiceIntances\" my-test-asg', 'Average', 300))"),
// Id: pulumi.String("capacity_sum"),
// },
// },
// },
// CustomizedLoadMetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedLoadMetricSpecificationArgs{
// MetricDataQueries: autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedLoadMetricSpecificationMetricDataQueryArray{
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedLoadMetricSpecificationMetricDataQueryArgs{
// Expression: pulumi.String("SUM(SEARCH('{AWS/EC2,AutoScalingGroupName} MetricName=\"CPUUtilization\" my-test-asg', 'Sum', 3600))"),
// Id: pulumi.String("load_sum"),
// },
// },
// },
// CustomizedScalingMetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationArgs{
// MetricDataQueries: autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArray{
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArgs{
// Expression: pulumi.String("SUM(SEARCH('{AWS/AutoScaling,AutoScalingGroupName} MetricName=\"GroupInServiceIntances\" my-test-asg', 'Average', 300))"),
// Id: pulumi.String("capacity_sum"),
// ReturnData: pulumi.Bool(false),
// },
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArgs{
// Expression: pulumi.String("SUM(SEARCH('{AWS/EC2,AutoScalingGroupName} MetricName=\"CPUUtilization\" my-test-asg', 'Sum', 300))"),
// Id: pulumi.String("load_sum"),
// ReturnData: pulumi.Bool(false),
// },
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArgs{
// Expression: pulumi.String("load_sum / (capacity_sum * PERIOD(capacity_sum) / 60)"),
// Id: pulumi.String("weighted_average"),
// },
// },
// },
// TargetValue: pulumi.Float64(10),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ### Create predictive scaling policy using customized scaling and predefined load metric
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// AutoscalingGroupName: pulumi.String("my-test-asg"),
// PolicyType: pulumi.String("PredictiveScaling"),
// PredictiveScalingConfiguration: &autoscaling.PolicyPredictiveScalingConfigurationArgs{
// MetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationArgs{
// CustomizedScalingMetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationArgs{
// MetricDataQueries: autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArray{
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryArgs{
// Id: pulumi.String("scaling"),
// MetricStat: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryMetricStatArgs{
// Metric: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryMetricStatMetricArgs{
// Dimensions: autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryMetricStatMetricDimensionArray{
// &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationCustomizedScalingMetricSpecificationMetricDataQueryMetricStatMetricDimensionArgs{
// Name: pulumi.String("AutoScalingGroupName"),
// Value: pulumi.String("my-test-asg"),
// },
// },
// MetricName: pulumi.String("CPUUtilization"),
// Namespace: pulumi.String("AWS/EC2"),
// },
// Stat: pulumi.String("Average"),
// },
// },
// },
// },
// PredefinedLoadMetricSpecification: &autoscaling.PolicyPredictiveScalingConfigurationMetricSpecificationPredefinedLoadMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGTotalCPUUtilization"),
// ResourceLabel: pulumi.String("testLabel"),
// },
// TargetValue: pulumi.Float64(10),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// AutoScaling scaling policy can be imported using the role autoscaling_group_name and name separated by `/`.
//
// ```sh
//
// $ pulumi import aws:autoscaling/policy:Policy test-policy asg-name/policy-name
//
// ```
type Policy struct {
pulumi.CustomResourceState
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
AdjustmentType pulumi.StringPtrOutput `pulumi:"adjustmentType"`
// ARN assigned by AWS to the scaling policy.
Arn pulumi.StringOutput `pulumi:"arn"`
// Name of the autoscaling group.
AutoscalingGroupName pulumi.StringOutput `pulumi:"autoscalingGroupName"`
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
Cooldown pulumi.IntPtrOutput `pulumi:"cooldown"`
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
EstimatedInstanceWarmup pulumi.IntPtrOutput `pulumi:"estimatedInstanceWarmup"`
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
MetricAggregationType pulumi.StringOutput `pulumi:"metricAggregationType"`
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
MinAdjustmentMagnitude pulumi.IntPtrOutput `pulumi:"minAdjustmentMagnitude"`
// Name of the policy.
Name pulumi.StringOutput `pulumi:"name"`
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
PolicyType pulumi.StringPtrOutput `pulumi:"policyType"`
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
PredictiveScalingConfiguration PolicyPredictiveScalingConfigurationPtrOutput `pulumi:"predictiveScalingConfiguration"`
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
ScalingAdjustment pulumi.IntPtrOutput `pulumi:"scalingAdjustment"`
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in step adjustments:
StepAdjustments PolicyStepAdjustmentArrayOutput `pulumi:"stepAdjustments"`
// Target tracking policy. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// PredefinedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGAverageCPUUtilization"),
// },
// TargetValue: pulumi.Float64(40),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in target tracking configuration:
TargetTrackingConfiguration PolicyTargetTrackingConfigurationPtrOutput `pulumi:"targetTrackingConfiguration"`
}
// NewPolicy registers a new resource with the given unique name, arguments, and options.
func NewPolicy(ctx *pulumi.Context,
name string, args *PolicyArgs, opts ...pulumi.ResourceOption) (*Policy, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AutoscalingGroupName == nil {
return nil, errors.New("invalid value for required argument 'AutoscalingGroupName'")
}
var resource Policy
err := ctx.RegisterResource("aws:autoscaling/policy:Policy", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPolicy gets an existing Policy 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 GetPolicy(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PolicyState, opts ...pulumi.ResourceOption) (*Policy, error) {
var resource Policy
err := ctx.ReadResource("aws:autoscaling/policy:Policy", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Policy resources.
type policyState struct {
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
AdjustmentType *string `pulumi:"adjustmentType"`
// ARN assigned by AWS to the scaling policy.
Arn *string `pulumi:"arn"`
// Name of the autoscaling group.
AutoscalingGroupName *string `pulumi:"autoscalingGroupName"`
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
Cooldown *int `pulumi:"cooldown"`
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
Enabled *bool `pulumi:"enabled"`
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
EstimatedInstanceWarmup *int `pulumi:"estimatedInstanceWarmup"`
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
MetricAggregationType *string `pulumi:"metricAggregationType"`
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
MinAdjustmentMagnitude *int `pulumi:"minAdjustmentMagnitude"`
// Name of the policy.
Name *string `pulumi:"name"`
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
PolicyType *string `pulumi:"policyType"`
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
PredictiveScalingConfiguration *PolicyPredictiveScalingConfiguration `pulumi:"predictiveScalingConfiguration"`
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
ScalingAdjustment *int `pulumi:"scalingAdjustment"`
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in step adjustments:
StepAdjustments []PolicyStepAdjustment `pulumi:"stepAdjustments"`
// Target tracking policy. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// PredefinedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGAverageCPUUtilization"),
// },
// TargetValue: pulumi.Float64(40),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in target tracking configuration:
TargetTrackingConfiguration *PolicyTargetTrackingConfiguration `pulumi:"targetTrackingConfiguration"`
}
type PolicyState struct {
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
AdjustmentType pulumi.StringPtrInput
// ARN assigned by AWS to the scaling policy.
Arn pulumi.StringPtrInput
// Name of the autoscaling group.
AutoscalingGroupName pulumi.StringPtrInput
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
Cooldown pulumi.IntPtrInput
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
Enabled pulumi.BoolPtrInput
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
EstimatedInstanceWarmup pulumi.IntPtrInput
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
MetricAggregationType pulumi.StringPtrInput
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
MinAdjustmentMagnitude pulumi.IntPtrInput
// Name of the policy.
Name pulumi.StringPtrInput
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
PolicyType pulumi.StringPtrInput
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
PredictiveScalingConfiguration PolicyPredictiveScalingConfigurationPtrInput
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
ScalingAdjustment pulumi.IntPtrInput
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in step adjustments:
StepAdjustments PolicyStepAdjustmentArrayInput
// Target tracking policy. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// PredefinedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGAverageCPUUtilization"),
// },
// TargetValue: pulumi.Float64(40),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in target tracking configuration:
TargetTrackingConfiguration PolicyTargetTrackingConfigurationPtrInput
}
func (PolicyState) ElementType() reflect.Type {
return reflect.TypeOf((*policyState)(nil)).Elem()
}
type policyArgs struct {
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
AdjustmentType *string `pulumi:"adjustmentType"`
// Name of the autoscaling group.
AutoscalingGroupName string `pulumi:"autoscalingGroupName"`
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
Cooldown *int `pulumi:"cooldown"`
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
Enabled *bool `pulumi:"enabled"`
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
EstimatedInstanceWarmup *int `pulumi:"estimatedInstanceWarmup"`
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
MetricAggregationType *string `pulumi:"metricAggregationType"`
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
MinAdjustmentMagnitude *int `pulumi:"minAdjustmentMagnitude"`
// Name of the policy.
Name *string `pulumi:"name"`
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
PolicyType *string `pulumi:"policyType"`
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
PredictiveScalingConfiguration *PolicyPredictiveScalingConfiguration `pulumi:"predictiveScalingConfiguration"`
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
ScalingAdjustment *int `pulumi:"scalingAdjustment"`
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in step adjustments:
StepAdjustments []PolicyStepAdjustment `pulumi:"stepAdjustments"`
// Target tracking policy. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// PredefinedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGAverageCPUUtilization"),
// },
// TargetValue: pulumi.Float64(40),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in target tracking configuration:
TargetTrackingConfiguration *PolicyTargetTrackingConfiguration `pulumi:"targetTrackingConfiguration"`
}
// The set of arguments for constructing a Policy resource.
type PolicyArgs struct {
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
AdjustmentType pulumi.StringPtrInput
// Name of the autoscaling group.
AutoscalingGroupName pulumi.StringInput
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
Cooldown pulumi.IntPtrInput
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
Enabled pulumi.BoolPtrInput
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
EstimatedInstanceWarmup pulumi.IntPtrInput
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
MetricAggregationType pulumi.StringPtrInput
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
MinAdjustmentMagnitude pulumi.IntPtrInput
// Name of the policy.
Name pulumi.StringPtrInput
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
PolicyType pulumi.StringPtrInput
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
PredictiveScalingConfiguration PolicyPredictiveScalingConfigurationPtrInput
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
ScalingAdjustment pulumi.IntPtrInput
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in step adjustments:
StepAdjustments PolicyStepAdjustmentArrayInput
// Target tracking policy. These have the following structure:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// TargetTrackingConfiguration: &autoscaling.PolicyTargetTrackingConfigurationArgs{
// PredefinedMetricSpecification: &autoscaling.PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs{
// PredefinedMetricType: pulumi.String("ASGAverageCPUUtilization"),
// },
// TargetValue: pulumi.Float64(40),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// The following fields are available in target tracking configuration:
TargetTrackingConfiguration PolicyTargetTrackingConfigurationPtrInput
}
func (PolicyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*policyArgs)(nil)).Elem()
}
type PolicyInput interface {
pulumi.Input
ToPolicyOutput() PolicyOutput
ToPolicyOutputWithContext(ctx context.Context) PolicyOutput
}
func (*Policy) ElementType() reflect.Type {
return reflect.TypeOf((**Policy)(nil)).Elem()
}
func (i *Policy) ToPolicyOutput() PolicyOutput {
return i.ToPolicyOutputWithContext(context.Background())
}
func (i *Policy) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyOutput)
}
// PolicyArrayInput is an input type that accepts PolicyArray and PolicyArrayOutput values.
// You can construct a concrete instance of `PolicyArrayInput` via:
//
// PolicyArray{ PolicyArgs{...} }
type PolicyArrayInput interface {
pulumi.Input
ToPolicyArrayOutput() PolicyArrayOutput
ToPolicyArrayOutputWithContext(context.Context) PolicyArrayOutput
}
type PolicyArray []PolicyInput
func (PolicyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Policy)(nil)).Elem()
}
func (i PolicyArray) ToPolicyArrayOutput() PolicyArrayOutput {
return i.ToPolicyArrayOutputWithContext(context.Background())
}
func (i PolicyArray) ToPolicyArrayOutputWithContext(ctx context.Context) PolicyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyArrayOutput)
}
// PolicyMapInput is an input type that accepts PolicyMap and PolicyMapOutput values.
// You can construct a concrete instance of `PolicyMapInput` via:
//
// PolicyMap{ "key": PolicyArgs{...} }
type PolicyMapInput interface {
pulumi.Input
ToPolicyMapOutput() PolicyMapOutput
ToPolicyMapOutputWithContext(context.Context) PolicyMapOutput
}
type PolicyMap map[string]PolicyInput
func (PolicyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Policy)(nil)).Elem()
}
func (i PolicyMap) ToPolicyMapOutput() PolicyMapOutput {
return i.ToPolicyMapOutputWithContext(context.Background())
}
func (i PolicyMap) ToPolicyMapOutputWithContext(ctx context.Context) PolicyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyMapOutput)
}
type PolicyOutput struct{ *pulumi.OutputState }
func (PolicyOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Policy)(nil)).Elem()
}
func (o PolicyOutput) ToPolicyOutput() PolicyOutput {
return o
}
func (o PolicyOutput) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput {
return o
}
// Whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are `ChangeInCapacity`, `ExactCapacity`, and `PercentChangeInCapacity`.
func (o PolicyOutput) AdjustmentType() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.StringPtrOutput { return v.AdjustmentType }).(pulumi.StringPtrOutput)
}
// ARN assigned by AWS to the scaling policy.
func (o PolicyOutput) Arn() pulumi.StringOutput {
return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
}
// Name of the autoscaling group.
func (o PolicyOutput) AutoscalingGroupName() pulumi.StringOutput {
return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.AutoscalingGroupName }).(pulumi.StringOutput)
}
// Amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
func (o PolicyOutput) Cooldown() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.IntPtrOutput { return v.Cooldown }).(pulumi.IntPtrOutput)
}
// Whether the scaling policy is enabled or disabled. Default: `true`.
//
// The following argument is only available to "SimpleScaling" and "StepScaling" type policies:
func (o PolicyOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// Estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group's specified cooldown period.
func (o PolicyOutput) EstimatedInstanceWarmup() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.IntPtrOutput { return v.EstimatedInstanceWarmup }).(pulumi.IntPtrOutput)
}
// Aggregation type for the policy's metrics. Valid values are "Minimum", "Maximum", and "Average". Without a value, AWS will treat the aggregation type as "Average".
func (o PolicyOutput) MetricAggregationType() pulumi.StringOutput {
return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.MetricAggregationType }).(pulumi.StringOutput)
}
// Minimum value to scale by when `adjustmentType` is set to `PercentChangeInCapacity`.
//
// The following arguments are only available to "SimpleScaling" type policies:
func (o PolicyOutput) MinAdjustmentMagnitude() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.IntPtrOutput { return v.MinAdjustmentMagnitude }).(pulumi.IntPtrOutput)
}
// Name of the policy.
func (o PolicyOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Policy type, either "SimpleScaling", "StepScaling", "TargetTrackingScaling", or "PredictiveScaling". If this value isn't provided, AWS will default to "SimpleScaling."
func (o PolicyOutput) PolicyType() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.StringPtrOutput { return v.PolicyType }).(pulumi.StringPtrOutput)
}
// Predictive scaling policy configuration to use with Amazon EC2 Auto Scaling.
func (o PolicyOutput) PredictiveScalingConfiguration() PolicyPredictiveScalingConfigurationPtrOutput {
return o.ApplyT(func(v *Policy) PolicyPredictiveScalingConfigurationPtrOutput { return v.PredictiveScalingConfiguration }).(PolicyPredictiveScalingConfigurationPtrOutput)
}
// Number of members by which to
// scale, when the adjustment bounds are breached. A positive value scales
// up. A negative value scales down.
func (o PolicyOutput) ScalingAdjustment() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Policy) pulumi.IntPtrOutput { return v.ScalingAdjustment }).(pulumi.IntPtrOutput)
}
// Set of adjustments that manage
// group scaling. These have the following structure:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := autoscaling.NewPolicy(ctx, "example", &autoscaling.PolicyArgs{
// StepAdjustments: autoscaling.PolicyStepAdjustmentArray{
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("1"),
// MetricIntervalUpperBound: pulumi.String("2"),
// ScalingAdjustment: -1,
// },
// &autoscaling.PolicyStepAdjustmentArgs{
// MetricIntervalLowerBound: pulumi.String("2"),
// MetricIntervalUpperBound: pulumi.String("3"),
// ScalingAdjustment: pulumi.Int(1),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// The following fields are available in step adjustments:
func (o PolicyOutput) StepAdjustments() PolicyStepAdjustmentArrayOutput {
return o.ApplyT(func(v *Policy) PolicyStepAdjustmentArrayOutput { return v.StepAdjustments }).(PolicyStepAdjustmentArrayOutput)
}
// Target tracking policy. These have the following structure: