@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-14T16:25:33.677Z") public class CfnScalingPolicy extends CfnResource implements IInspectable
The AWS::AutoScaling::ScalingPolicy
resource specifies an Amazon EC2 Auto Scaling scaling policy so that the Auto Scaling group can scale the number of instances available for your application.
For more information about using scaling policies to scale your Auto Scaling group automatically, see Dynamic scaling and Predictive scaling in the Amazon EC2 Auto Scaling User Guide .
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.autoscaling.*; CfnScalingPolicy cfnScalingPolicy = CfnScalingPolicy.Builder.create(this, "MyCfnScalingPolicy") .autoScalingGroupName("autoScalingGroupName") // the properties below are optional .adjustmentType("adjustmentType") .cooldown("cooldown") .estimatedInstanceWarmup(123) .metricAggregationType("metricAggregationType") .minAdjustmentMagnitude(123) .policyType("policyType") .predictiveScalingConfiguration(PredictiveScalingConfigurationProperty.builder() .metricSpecifications(List.of(PredictiveScalingMetricSpecificationProperty.builder() .targetValue(123) // the properties below are optional .customizedCapacityMetricSpecification(PredictiveScalingCustomizedCapacityMetricProperty.builder() .metricDataQueries(List.of(MetricDataQueryProperty.builder() .id("id") // the properties below are optional .expression("expression") .label("label") .metricStat(MetricStatProperty.builder() .metric(MetricProperty.builder() .metricName("metricName") .namespace("namespace") // the properties below are optional .dimensions(List.of(MetricDimensionProperty.builder() .name("name") .value("value") .build())) .build()) .stat("stat") // the properties below are optional .unit("unit") .build()) .returnData(false) .build())) .build()) .customizedLoadMetricSpecification(PredictiveScalingCustomizedLoadMetricProperty.builder() .metricDataQueries(List.of(MetricDataQueryProperty.builder() .id("id") // the properties below are optional .expression("expression") .label("label") .metricStat(MetricStatProperty.builder() .metric(MetricProperty.builder() .metricName("metricName") .namespace("namespace") // the properties below are optional .dimensions(List.of(MetricDimensionProperty.builder() .name("name") .value("value") .build())) .build()) .stat("stat") // the properties below are optional .unit("unit") .build()) .returnData(false) .build())) .build()) .customizedScalingMetricSpecification(PredictiveScalingCustomizedScalingMetricProperty.builder() .metricDataQueries(List.of(MetricDataQueryProperty.builder() .id("id") // the properties below are optional .expression("expression") .label("label") .metricStat(MetricStatProperty.builder() .metric(MetricProperty.builder() .metricName("metricName") .namespace("namespace") // the properties below are optional .dimensions(List.of(MetricDimensionProperty.builder() .name("name") .value("value") .build())) .build()) .stat("stat") // the properties below are optional .unit("unit") .build()) .returnData(false) .build())) .build()) .predefinedLoadMetricSpecification(PredictiveScalingPredefinedLoadMetricProperty.builder() .predefinedMetricType("predefinedMetricType") // the properties below are optional .resourceLabel("resourceLabel") .build()) .predefinedMetricPairSpecification(PredictiveScalingPredefinedMetricPairProperty.builder() .predefinedMetricType("predefinedMetricType") // the properties below are optional .resourceLabel("resourceLabel") .build()) .predefinedScalingMetricSpecification(PredictiveScalingPredefinedScalingMetricProperty.builder() .predefinedMetricType("predefinedMetricType") // the properties below are optional .resourceLabel("resourceLabel") .build()) .build())) // the properties below are optional .maxCapacityBreachBehavior("maxCapacityBreachBehavior") .maxCapacityBuffer(123) .mode("mode") .schedulingBufferTime(123) .build()) .scalingAdjustment(123) .stepAdjustments(List.of(StepAdjustmentProperty.builder() .scalingAdjustment(123) // the properties below are optional .metricIntervalLowerBound(123) .metricIntervalUpperBound(123) .build())) .targetTrackingConfiguration(TargetTrackingConfigurationProperty.builder() .targetValue(123) // the properties below are optional .customizedMetricSpecification(CustomizedMetricSpecificationProperty.builder() .metricName("metricName") .namespace("namespace") .statistic("statistic") // the properties below are optional .dimensions(List.of(MetricDimensionProperty.builder() .name("name") .value("value") .build())) .unit("unit") .build()) .disableScaleIn(false) .predefinedMetricSpecification(PredefinedMetricSpecificationProperty.builder() .predefinedMetricType("predefinedMetricType") // the properties below are optional .resourceLabel("resourceLabel") .build()) .build()) .build();
Modifier and Type | Class and Description |
---|---|
static class |
CfnScalingPolicy.Builder
A fluent builder for
CfnScalingPolicy . |
static interface |
CfnScalingPolicy.CustomizedMetricSpecificationProperty
Contains customized metric specification information for a target tracking scaling policy for Amazon EC2 Auto Scaling.
|
static interface |
CfnScalingPolicy.MetricDataQueryProperty
The metric data to return.
|
static interface |
CfnScalingPolicy.MetricDimensionProperty
`MetricDimension` specifies a name/value pair that is part of the identity of a CloudWatch metric for the `Dimensions` property of the [AWS::AutoScaling::ScalingPolicy CustomizedMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-customizedmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.MetricProperty
Represents a specific metric.
|
static interface |
CfnScalingPolicy.MetricStatProperty
`MetricStat` is a property of the [AWS::AutoScaling::ScalingPolicy MetricDataQuery](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-metricdataquery.html) property type.
|
static interface |
CfnScalingPolicy.PredefinedMetricSpecificationProperty
Contains predefined metric specification information for a target tracking scaling policy for Amazon EC2 Auto Scaling.
|
static interface |
CfnScalingPolicy.PredictiveScalingConfigurationProperty
`PredictiveScalingConfiguration` is a property of the [AWS::AutoScaling::ScalingPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html) resource that specifies a predictive scaling policy for Amazon EC2 Auto Scaling.
|
static interface |
CfnScalingPolicy.PredictiveScalingCustomizedCapacityMetricProperty
Contains capacity metric information for the `CustomizedCapacityMetricSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingCustomizedLoadMetricProperty
Contains load metric information for the `CustomizedLoadMetricSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingCustomizedScalingMetricProperty
Contains scaling metric information for the `CustomizedScalingMetricSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingMetricSpecificationProperty
A structure that specifies a metric specification for the `MetricSpecifications` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingconfiguration.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingPredefinedLoadMetricProperty
Contains load metric information for the `PredefinedLoadMetricSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingPredefinedMetricPairProperty
Contains metric pair information for the `PredefinedMetricPairSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.PredictiveScalingPredefinedScalingMetricProperty
Contains scaling metric information for the `PredefinedScalingMetricSpecification` property of the [AWS::AutoScaling::ScalingPolicy PredictiveScalingMetricSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-scalingpolicy-predictivescalingmetricspecification.html) property type.
|
static interface |
CfnScalingPolicy.StepAdjustmentProperty
`StepAdjustment` specifies a step adjustment for the `StepAdjustments` property of the [AWS::AutoScaling::ScalingPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html) resource.
|
static interface |
CfnScalingPolicy.TargetTrackingConfigurationProperty
`TargetTrackingConfiguration` is a property of the [AWS::AutoScaling::ScalingPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html) resource that specifies a target tracking scaling policy configuration for Amazon EC2 Auto Scaling.
|
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
IConstruct.Jsii$Default
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnScalingPolicy(Construct scope,
java.lang.String id,
CfnScalingPolicyProps props)
Create a new `AWS::AutoScaling::ScalingPolicy`.
|
protected |
CfnScalingPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnScalingPolicy(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAdjustmentType()
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage).
|
java.lang.String |
getAttrArn() |
java.lang.String |
getAttrPolicyName()
Returns the name of a scaling policy.
|
java.lang.String |
getAutoScalingGroupName()
The name of the Auto Scaling group.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.lang.String |
getCooldown()
A cooldown period, in seconds, that applies to a specific simple scaling policy.
|
java.lang.Number |
getEstimatedInstanceWarmup()
*Not needed if the default instance warmup is defined for the group.*.
|
java.lang.String |
getMetricAggregationType()
The aggregation type for the CloudWatch metrics.
|
java.lang.Number |
getMinAdjustmentMagnitude()
The minimum value to scale by when the adjustment type is `PercentChangeInCapacity` .
|
java.lang.String |
getPolicyType()
One of the following policy types:.
|
java.lang.Object |
getPredictiveScalingConfiguration()
A predictive scaling policy.
|
java.lang.Number |
getScalingAdjustment()
The amount by which to scale, based on the specified adjustment type.
|
java.lang.Object |
getStepAdjustments()
A set of adjustments that enable you to scale based on the size of the alarm breach.
|
java.lang.Object |
getTargetTrackingConfiguration()
A target tracking scaling policy.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
void |
setAdjustmentType(java.lang.String value)
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage).
|
void |
setAutoScalingGroupName(java.lang.String value)
The name of the Auto Scaling group.
|
void |
setCooldown(java.lang.String value)
A cooldown period, in seconds, that applies to a specific simple scaling policy.
|
void |
setEstimatedInstanceWarmup(java.lang.Number value)
*Not needed if the default instance warmup is defined for the group.*.
|
void |
setMetricAggregationType(java.lang.String value)
The aggregation type for the CloudWatch metrics.
|
void |
setMinAdjustmentMagnitude(java.lang.Number value)
The minimum value to scale by when the adjustment type is `PercentChangeInCapacity` .
|
void |
setPolicyType(java.lang.String value)
One of the following policy types:.
|
void |
setPredictiveScalingConfiguration(CfnScalingPolicy.PredictiveScalingConfigurationProperty value)
A predictive scaling policy.
|
void |
setPredictiveScalingConfiguration(IResolvable value)
A predictive scaling policy.
|
void |
setScalingAdjustment(java.lang.Number value)
The amount by which to scale, based on the specified adjustment type.
|
void |
setStepAdjustments(IResolvable value)
A set of adjustments that enable you to scale based on the size of the alarm breach.
|
void |
setStepAdjustments(java.util.List<java.lang.Object> value)
A set of adjustments that enable you to scale based on the size of the alarm breach.
|
void |
setTargetTrackingConfiguration(CfnScalingPolicy.TargetTrackingConfigurationProperty value)
A target tracking scaling policy.
|
void |
setTargetTrackingConfiguration(IResolvable value)
A target tracking scaling policy.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
public static final java.lang.String CFN_RESOURCE_TYPE_NAME
protected CfnScalingPolicy(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnScalingPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnScalingPolicy(Construct scope, java.lang.String id, CfnScalingPolicyProps props)
scope
- - scope in which this resource is defined. This parameter is required.id
- - scoped id of the resource. This parameter is required.props
- - resource properties. This parameter is required.public void inspect(TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.public java.lang.String getAttrArn()
public java.lang.String getAttrPolicyName()
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public java.lang.String getAutoScalingGroupName()
public void setAutoScalingGroupName(java.lang.String value)
public java.lang.String getAdjustmentType()
The valid values are ChangeInCapacity
, ExactCapacity
, and PercentChangeInCapacity
.
Required if the policy type is StepScaling
or SimpleScaling
. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide .
public void setAdjustmentType(java.lang.String value)
The valid values are ChangeInCapacity
, ExactCapacity
, and PercentChangeInCapacity
.
Required if the policy type is StepScaling
or SimpleScaling
. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide .
public java.lang.String getCooldown()
When a cooldown period is specified here, it overrides the default cooldown.
Valid only if the policy type is SimpleScaling
. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide .
Default: None
public void setCooldown(java.lang.String value)
When a cooldown period is specified here, it overrides the default cooldown.
Valid only if the policy type is SimpleScaling
. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide .
Default: None
public java.lang.Number getEstimatedInstanceWarmup()
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. This warm-up period applies to instances launched due to a specific target tracking or step scaling policy. When a warm-up period is specified here, it overrides the default instance warmup.
Valid only if the policy type is TargetTrackingScaling
or StepScaling
.
The default is to use the value for the default instance warmup defined for the group. If default instance warmup is null, then
EstimatedInstanceWarmup
falls back to the value of default cooldown.
public void setEstimatedInstanceWarmup(java.lang.Number value)
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. This warm-up period applies to instances launched due to a specific target tracking or step scaling policy. When a warm-up period is specified here, it overrides the default instance warmup.
Valid only if the policy type is TargetTrackingScaling
or StepScaling
.
The default is to use the value for the default instance warmup defined for the group. If default instance warmup is null, then
EstimatedInstanceWarmup
falls back to the value of default cooldown.
public java.lang.String getMetricAggregationType()
The valid values are Minimum
, Maximum
, and Average
. If the aggregation type is null, the value is treated as Average
.
Valid only if the policy type is StepScaling
.
public void setMetricAggregationType(java.lang.String value)
The valid values are Minimum
, Maximum
, and Average
. If the aggregation type is null, the value is treated as Average
.
Valid only if the policy type is StepScaling
.
public java.lang.Number getMinAdjustmentMagnitude()
For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude
of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude
of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.
Valid only if the policy type is StepScaling
or SimpleScaling
. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide .
Some Auto Scaling groups use instance weights. In this case, set the
MinAdjustmentMagnitude
to a value that is at least as large as your largest instance weight.
public void setMinAdjustmentMagnitude(java.lang.Number value)
For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude
of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude
of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.
Valid only if the policy type is StepScaling
or SimpleScaling
. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide .
Some Auto Scaling groups use instance weights. In this case, set the
MinAdjustmentMagnitude
to a value that is at least as large as your largest instance weight.
public java.lang.String getPolicyType()
TargetTrackingScaling
StepScaling
SimpleScaling
(default)PredictiveScaling
public void setPolicyType(java.lang.String value)
TargetTrackingScaling
StepScaling
SimpleScaling
(default)PredictiveScaling
public java.lang.Object getPredictiveScalingConfiguration()
Predefined metrics include CPU utilization, network in/out, and the Application Load Balancer request count.
Required if the policy type is PredictiveScaling
.
public void setPredictiveScalingConfiguration(IResolvable value)
Predefined metrics include CPU utilization, network in/out, and the Application Load Balancer request count.
Required if the policy type is PredictiveScaling
.
public void setPredictiveScalingConfiguration(CfnScalingPolicy.PredictiveScalingConfigurationProperty value)
Predefined metrics include CPU utilization, network in/out, and the Application Load Balancer request count.
Required if the policy type is PredictiveScaling
.
public java.lang.Number getScalingAdjustment()
A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a positive value.
Required if the policy type is SimpleScaling
. (Not used with any other policy type.)
public void setScalingAdjustment(java.lang.Number value)
A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a positive value.
Required if the policy type is SimpleScaling
. (Not used with any other policy type.)
public java.lang.Object getStepAdjustments()
Required if the policy type is StepScaling
. (Not used with any other policy type.)
public void setStepAdjustments(IResolvable value)
Required if the policy type is StepScaling
. (Not used with any other policy type.)
public void setStepAdjustments(java.util.List<java.lang.Object> value)
Required if the policy type is StepScaling
. (Not used with any other policy type.)
public java.lang.Object getTargetTrackingConfiguration()
The following predefined metrics are available:
ASGAverageCPUUtilization
ASGAverageNetworkIn
ASGAverageNetworkOut
ALBRequestCountPerTarget
If you specify ALBRequestCountPerTarget
for the metric, you must specify the ResourceLabel
property with the PredefinedMetricSpecification
.
Required if the policy type is TargetTrackingScaling
.
public void setTargetTrackingConfiguration(IResolvable value)
The following predefined metrics are available:
ASGAverageCPUUtilization
ASGAverageNetworkIn
ASGAverageNetworkOut
ALBRequestCountPerTarget
If you specify ALBRequestCountPerTarget
for the metric, you must specify the ResourceLabel
property with the PredefinedMetricSpecification
.
Required if the policy type is TargetTrackingScaling
.
public void setTargetTrackingConfiguration(CfnScalingPolicy.TargetTrackingConfigurationProperty value)
The following predefined metrics are available:
ASGAverageCPUUtilization
ASGAverageNetworkIn
ASGAverageNetworkOut
ALBRequestCountPerTarget
If you specify ALBRequestCountPerTarget
for the metric, you must specify the ResourceLabel
property with the PredefinedMetricSpecification
.
Required if the policy type is TargetTrackingScaling
.