diff --git a/packages/aws-cdk-lib/aws-autoscaling/lib/step-scaling-policy.ts b/packages/aws-cdk-lib/aws-autoscaling/lib/step-scaling-policy.ts index eed4950e7e720..937c92c0b80b1 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/lib/step-scaling-policy.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/lib/step-scaling-policy.ts @@ -147,7 +147,7 @@ export class StepScalingPolicy extends Construct { const threshold = intervals[alarms.lowerAlarmIntervalIndex].upper; this.lowerAction = new StepScalingAction(this, 'LowerPolicy', { - adjustmentType: props.adjustmentType, + adjustmentType, cooldown: props.cooldown, estimatedInstanceWarmup: props.estimatedInstanceWarmup, metricAggregationType: props.metricAggregationType ?? aggregationTypeFromMetric(props.metric), @@ -179,7 +179,7 @@ export class StepScalingPolicy extends Construct { const threshold = intervals[alarms.upperAlarmIntervalIndex].lower; this.upperAction = new StepScalingAction(this, 'UpperPolicy', { - adjustmentType: props.adjustmentType, + adjustmentType, cooldown: props.cooldown, estimatedInstanceWarmup: props.estimatedInstanceWarmup, metricAggregationType: props.metricAggregationType ?? aggregationTypeFromMetric(props.metric), diff --git a/packages/aws-cdk-lib/aws-autoscaling/test/scaling.test.ts b/packages/aws-cdk-lib/aws-autoscaling/test/scaling.test.ts index dc4a564d75221..f8dd19b431812 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/test/scaling.test.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/test/scaling.test.ts @@ -294,6 +294,28 @@ test('step scaling from percentile metric', () => { }); }); +test('step scaling with adjustmentType by default', () => { + // GIVEN + const stack = new cdk.Stack(); + const fixture = new ASGFixture(stack, 'Fixture'); + + // WHEN + fixture.asg.scaleOnMetric('Tracking', { + metric: new cloudwatch.Metric({ namespace: 'Test', metricName: 'Metric', statistic: 'p99' }), + scalingSteps: [ + { upper: 0, change: -1 }, + { lower: 100, change: +1 }, + { lower: 500, change: +5 }, + ], + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AutoScaling::ScalingPolicy', { + PolicyType: 'StepScaling', + AdjustmentType: 'ChangeInCapacity', + }); +}); + test('step scaling with evaluation period configured', () => { // GIVEN const stack = new cdk.Stack();