Skip to content
v2.278.0

AdjustmentType Enum ​

How adjustment numbers are interpreted.

Example ​

ts
declare const autoScalingGroup: autoscaling.AutoScalingGroup;

const workerUtilizationMetric = new cloudwatch.Metric({
    namespace: 'MyService',
    metricName: 'WorkerUtilization'
});

autoScalingGroup.scaleOnMetric('ScaleToCPU', {
  metric: workerUtilizationMetric,
  scalingSteps: [
    { upper: 10, change: -1 },
    { lower: 50, change: +1 },
    { lower: 70, change: +3 },
  ],
  evaluationPeriods: 10,
  datapointsToAlarm: 5,

  // Change this to AdjustmentType.PERCENT_CHANGE_IN_CAPACITY to interpret the
  // 'change' numbers before as percentages instead of capacity counts.
  adjustmentType: autoscaling.AdjustmentType.CHANGE_IN_CAPACITY,
});
python
# auto_scaling_group: autoscaling.AutoScalingGroup


worker_utilization_metric = cloudwatch.Metric(
    namespace="MyService",
    metric_name="WorkerUtilization"
)

auto_scaling_group.scale_on_metric("ScaleToCPU",
    metric=worker_utilization_metric,
    scaling_steps=[autoscaling.ScalingInterval(upper=10, change=-1), autoscaling.ScalingInterval(lower=50, change=+1), autoscaling.ScalingInterval(lower=70, change=+3)
    ],
    evaluation_periods=10,
    datapoints_to_alarm=5,

    # Change this to AdjustmentType.PERCENT_CHANGE_IN_CAPACITY to interpret the
    # 'change' numbers before as percentages instead of capacity counts.
    adjustment_type=autoscaling.AdjustmentType.CHANGE_IN_CAPACITY
)
java
AutoScalingGroup autoScalingGroup;


Metric workerUtilizationMetric = Metric.Builder.create()
        .namespace("MyService")
        .metricName("WorkerUtilization")
        .build();

autoScalingGroup.scaleOnMetric("ScaleToCPU", BasicStepScalingPolicyProps.builder()
        .metric(workerUtilizationMetric)
        .scalingSteps(List.of(ScalingInterval.builder().upper(10).change(-1).build(), ScalingInterval.builder().lower(50).change(+1).build(), ScalingInterval.builder().lower(70).change(+3).build()))
        .evaluationPeriods(10)
        .datapointsToAlarm(5)

        // Change this to AdjustmentType.PERCENT_CHANGE_IN_CAPACITY to interpret the
        // 'change' numbers before as percentages instead of capacity counts.
        .adjustmentType(AdjustmentType.CHANGE_IN_CAPACITY)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
AutoScalingGroup autoScalingGroup;


var workerUtilizationMetric = new Metric(new MetricProps {
    Namespace = "MyService",
    MetricName = "WorkerUtilization"
});

autoScalingGroup.ScaleOnMetric("ScaleToCPU", new BasicStepScalingPolicyProps {
    Metric = workerUtilizationMetric,
    ScalingSteps = new [] { new ScalingInterval { Upper = 10, Change = -1 }, new ScalingInterval { Lower = 50, Change = +1 }, new ScalingInterval { Lower = 70, Change = +3 } },
    EvaluationPeriods = 10,
    DatapointsToAlarm = 5,

    // Change this to AdjustmentType.PERCENT_CHANGE_IN_CAPACITY to interpret the
    // 'change' numbers before as percentages instead of capacity counts.
    AdjustmentType = AdjustmentType.CHANGE_IN_CAPACITY
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var autoScalingGroup AutoScalingGroup


workerUtilizationMetric := cloudwatch.NewMetric(&MetricProps{
	Namespace: jsii.String("MyService"),
	MetricName: jsii.String("WorkerUtilization"),
})

autoScalingGroup.scaleOnMetric(jsii.String("ScaleToCPU"), &BasicStepScalingPolicyProps{
	Metric: workerUtilizationMetric,
	ScalingSteps: []ScalingInterval{
		&ScalingInterval{
			Upper: jsii.Number(10),
			Change: -jsii.Number(1),
		},
		&ScalingInterval{
			Lower: jsii.Number(50),
			Change: +jsii.Number(1),
		},
		&ScalingInterval{
			Lower: jsii.Number(70),
			Change: +jsii.Number(3),
		},
	},
	EvaluationPeriods: jsii.Number(10),
	DatapointsToAlarm: jsii.Number(5),

	// Change this to AdjustmentType.PERCENT_CHANGE_IN_CAPACITY to interpret the
	// 'change' numbers before as percentages instead of capacity counts.
	AdjustmentType: autoscaling.AdjustmentType_CHANGE_IN_CAPACITY,
})

Members ​

MemberDescription
CHANGE_IN_CAPACITYAdd the adjustment number to the current capacity.
PERCENT_CHANGE_IN_CAPACITYAdd this percentage of the current capacity to itself.
EXACT_CAPACITYMake the capacity equal to the exact number given.

Referenced by ​