TargetTrackingScalingPolicy
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
import { aws_autoscaling as interfaces_autoscaling } from 'aws-cdk-lib/interfaces';
declare const autoScalingGroupRef: interfaces_autoscaling.IAutoScalingGroupRef;
declare const metric: cloudwatch.Metric;
const targetTrackingScalingPolicy = new autoscaling.TargetTrackingScalingPolicy(this, 'MyTargetTrackingScalingPolicy', {
autoScalingGroup: autoScalingGroupRef,
targetValue: 123,
// the properties below are optional
cooldown: cdk.Duration.minutes(30),
customMetric: metric,
disableScaleIn: false,
estimatedInstanceWarmup: cdk.Duration.minutes(30),
predefinedMetric: autoscaling.PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION,
resourceLabel: 'resourceLabel',
});
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_autoscaling as autoscaling
from aws_cdk import aws_cloudwatch as cloudwatch
from aws_cdk.interfaces import aws_autoscaling as interfaces_autoscaling
# auto_scaling_group_ref: interfaces_autoscaling.IAutoScalingGroupRef
# metric: cloudwatch.Metric
target_tracking_scaling_policy = autoscaling.TargetTrackingScalingPolicy(self, "MyTargetTrackingScalingPolicy",
auto_scaling_group=auto_scaling_group_ref,
target_value=123,
# the properties below are optional
cooldown=cdk.Duration.minutes(30),
custom_metric=metric,
disable_scale_in=False,
estimated_instance_warmup=cdk.Duration.minutes(30),
predefined_metric=autoscaling.PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION,
resource_label="resourceLabel"
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.autoscaling.*;
import software.amazon.awscdk.services.cloudwatch.*;
import software.amazon.awscdk.interfaces.autoscaling.*;
IAutoScalingGroupRef autoScalingGroupRef;
Metric metric;
TargetTrackingScalingPolicy targetTrackingScalingPolicy = TargetTrackingScalingPolicy.Builder.create(this, "MyTargetTrackingScalingPolicy")
.autoScalingGroup(autoScalingGroupRef)
.targetValue(123)
// the properties below are optional
.cooldown(Duration.minutes(30))
.customMetric(metric)
.disableScaleIn(false)
.estimatedInstanceWarmup(Duration.minutes(30))
.predefinedMetric(PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION)
.resourceLabel("resourceLabel")
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.AutoScaling;
using Amazon.CDK.AWS.CloudWatch;
using Amazon.CDK.Interfaces.AutoScaling;
IAutoScalingGroupRef autoScalingGroupRef;
Metric metric;
var targetTrackingScalingPolicy = new TargetTrackingScalingPolicy(this, "MyTargetTrackingScalingPolicy", new TargetTrackingScalingPolicyProps {
AutoScalingGroup = autoScalingGroupRef,
TargetValue = 123,
// the properties below are optional
Cooldown = Duration.Minutes(30),
CustomMetric = metric,
DisableScaleIn = false,
EstimatedInstanceWarmup = Duration.Minutes(30),
PredefinedMetric = PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION,
ResourceLabel = "resourceLabel"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var autoScalingGroupRef IAutoScalingGroupRef
var metric Metric
targetTrackingScalingPolicy := awscdk.Aws_autoscaling.NewTargetTrackingScalingPolicy(this, jsii.String("MyTargetTrackingScalingPolicy"), &TargetTrackingScalingPolicyProps{
AutoScalingGroup: autoScalingGroupRef,
TargetValue: jsii.Number(123),
// the properties below are optional
Cooldown: cdk.Duration_Minutes(jsii.Number(30)),
CustomMetric: metric,
DisableScaleIn: jsii.Boolean(false),
EstimatedInstanceWarmup: cdk.Duration_*Minutes(jsii.Number(30)),
PredefinedMetric: awscdk.*Aws_autoscaling.PredefinedMetric_ASG_AVERAGE_CPU_UTILIZATION,
ResourceLabel: jsii.String("resourceLabel"),
})
Initializer
new TargetTrackingScalingPolicy(scope: Construct, id: string, props: TargetTrackingScalingPolicyProps)
TargetTrackingScalingPolicy(scope: Construct, id: str, props: TargetTrackingScalingPolicyProps)
new TargetTrackingScalingPolicy(Construct scope, String id, TargetTrackingScalingPolicyProps props)
new TargetTrackingScalingPolicy(Construct scope, string id, TargetTrackingScalingPolicyProps props)
NewTargetTrackingScalingPolicy(Scope Construct, Id *string, Props TargetTrackingScalingPolicyProps)
Construct Props
autoScalingGroupIAutoScalingGroupRefauto_scaling_groupIAutoScalingGroupRefautoScalingGroupIAutoScalingGroupRefAutoScalingGroupIAutoScalingGroupRefAutoScalingGroupIAutoScalingGroupRefrequired#cooldownoptionalDurationcooldownoptionalDurationcooldownoptionalDurationCooldownoptionalDurationCooldownoptionalDuration#Default: The default cooldown configured on the AutoScalingGroup.
customMetricoptionalIMetriccustom_metricoptionalIMetriccustomMetricoptionalIMetricCustomMetricoptionalIMetricCustomMetricoptionalIMetric#Default: No custom metric.
notes
The metric must track utilization. Scaling out will happen if the metric is higher than the target value, scaling in will happen in the metric is lower than the target value.
Exactly one of customMetric or predefinedMetric must be specified.
disableScaleInoptionalbooleandisable_scale_inoptionalbooldisableScaleInoptionalBooleanDisableScaleInoptionalboolDisableScaleInoptional*bool= false#If the value is true, scale in is disabled and the target tracking policy won't remove capacity from the autoscaling group. Otherwise, scale in is enabled and the target tracking policy can remove capacity from the group.
estimatedInstanceWarmupoptionalDurationestimated_instance_warmupoptionalDurationestimatedInstanceWarmupoptionalDurationEstimatedInstanceWarmupoptionalDurationEstimatedInstanceWarmupoptionalDuration#Default: Same as the cooldown.
predefinedMetricoptionalPredefinedMetricpredefined_metricoptionalPredefinedMetricpredefinedMetricoptionalPredefinedMetricPredefinedMetricoptionalPredefinedMetricPredefinedMetricoptionalPredefinedMetric#Default: No predefined metric.
notes
The metric must track utilization. Scaling out will happen if the metric is higher than the target value, scaling in will happen in the metric is lower than the target value.
Exactly one of customMetric or predefinedMetric must be specified.
resourceLabeloptionalstringresource_labeloptionalstrresourceLabeloptionalStringResourceLabeloptionalstringResourceLabeloptional*string#Default: No resource label.
Should be supplied if the predefined metric is ALBRequestCountPerTarget, and the format should be:
app/<load-balancer-name>/<load-balancer-id>/targetgroup/<target-group-name>/<target-group-id>
targetValuenumbertarget_valueint | floattargetValueNumberTargetValuedoubleTargetValue*float64required#Properties
Methods
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.
1 parameter · returns
Parameters
mixinsmixinsmixinsmixinsMixins— The mixins to apply.
Returns: This construct for chaining