Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autoscaling): step scaling without adjustment type fails #28794

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class StepScalingPolicy extends Construct {
const threshold = intervals[alarms.lowerAlarmIntervalIndex].upper;

this.lowerAction = new StepScalingAction(this, 'LowerPolicy', {
adjustmentType: props.adjustmentType,
adjustmentType,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property is defined here.

cooldown: props.cooldown,
estimatedInstanceWarmup: props.estimatedInstanceWarmup,
metricAggregationType: props.metricAggregationType ?? aggregationTypeFromMetric(props.metric),
Expand Down Expand Up @@ -143,7 +143,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),
Expand Down
22 changes: 22 additions & 0 deletions packages/aws-cdk-lib/aws-autoscaling/test/scaling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading