From eb5fc488474772709936773eb96bb93e42e94cd8 Mon Sep 17 00:00:00 2001 From: Basile Deustua Date: Fri, 1 Jul 2022 16:17:03 +0200 Subject: [PATCH] feat(autoscaling): step scaling policy supports estimatedInstanceWarmup property (#20936) Fix https://github.com/aws/aws-cdk/issues/10514 ---- ### All Submissions: * [ x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts | 2 ++ packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts index ff96848cf048e..2632d6ff0271d 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts @@ -108,6 +108,7 @@ export class StepScalingPolicy extends Construct { this.lowerAction = new StepScalingAction(this, 'LowerPolicy', { adjustmentType: props.adjustmentType, cooldown: props.cooldown, + estimatedInstanceWarmup: props.estimatedInstanceWarmup, metricAggregationType: props.metricAggregationType ?? aggregationTypeFromMetric(props.metric), minAdjustmentMagnitude: props.minAdjustmentMagnitude, autoScalingGroup: props.autoScalingGroup, @@ -138,6 +139,7 @@ export class StepScalingPolicy extends Construct { this.upperAction = new StepScalingAction(this, 'UpperPolicy', { adjustmentType: props.adjustmentType, cooldown: props.cooldown, + estimatedInstanceWarmup: props.estimatedInstanceWarmup, metricAggregationType: props.metricAggregationType ?? aggregationTypeFromMetric(props.metric), minAdjustmentMagnitude: props.minAdjustmentMagnitude, autoScalingGroup: props.autoScalingGroup, diff --git a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts index 8d47c5746100b..18a9b4c351164 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts @@ -205,6 +205,7 @@ describe('scaling', () => { namespace: 'Henk', dimensionsMap: { Mustache: 'Bushy' }, }), + estimatedInstanceWarmup: cdk.Duration.seconds(150), // Adjust the number of legs to be closer to 2 scalingSteps: [ { lower: 0, upper: 2, change: +1 }, @@ -241,6 +242,7 @@ describe('scaling', () => { Template.fromStack(stack).hasResourceProperties('AWS::AutoScaling::ScalingPolicy', { MetricAggregationType: 'Average', PolicyType: 'StepScaling', + EstimatedInstanceWarmup: 150, StepAdjustments: [ { MetricIntervalUpperBound: 0,