AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the AWS Auto Scaling PutScalingPolicy API operation.

Syntax

Write-ASScalingPolicy
-AutoScalingGroupName <String>
-PolicyName <String>
-AdjustmentType <String>
-Cooldown <Int32>
-CustomizedMetricSpecification_Dimension <MetricDimension[]>
-TargetTrackingConfiguration_DisableScaleIn <Boolean>
-Enabled <Boolean>
-EstimatedInstanceWarmup <Int32>
-PredictiveScalingConfiguration_MaxCapacityBreachBehavior <PredictiveScalingMaxCapacityBreachBehavior>
-PredictiveScalingConfiguration_MaxCapacityBuffer <Int32>
-MetricAggregationType <String>
-CustomizedMetricSpecification_MetricName <String>
-CustomizedMetricSpecification_Metric <TargetTrackingMetricDataQuery[]>
-PredictiveScalingConfiguration_MetricSpecification <PredictiveScalingMetricSpecification[]>
-MinAdjustmentMagnitude <Int32>
-MinAdjustmentStep <Int32>
-PredictiveScalingConfiguration_Mode <PredictiveScalingMode>
-CustomizedMetricSpecification_Namespace <String>
-PolicyType <String>
-PredefinedMetricSpecification_PredefinedMetricType <MetricType>
-PredefinedMetricSpecification_ResourceLabel <String>
-ScalingAdjustment <Int32>
-PredictiveScalingConfiguration_SchedulingBufferTime <Int32>
-CustomizedMetricSpecification_Statistic <MetricStatistic>
-StepAdjustment <StepAdjustment[]>
-TargetTrackingConfiguration_TargetValue <Double>
-CustomizedMetricSpecification_Unit <String>
-Select <String>
-PassThru <SwitchParameter>
-Force <SwitchParameter>
-ClientConfig <AmazonAutoScalingConfig>

Description

Creates or updates a scaling policy for an Auto Scaling group. Scaling policies are used to scale an Auto Scaling group based on configurable metrics. If no policies are defined, the dynamic scaling and predictive scaling features are not used. For more information about using dynamic scaling, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide. For more information about using predictive scaling, see Predictive scaling for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. You can view the scaling policies for an Auto Scaling group using the DescribePolicies API call. If you are no longer using a scaling policy, you can delete it by calling the DeletePolicy API.

Parameters

-AdjustmentType <String>
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). 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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-AutoScalingGroupName <String>
The name of the Auto Scaling group.
Required?True
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-ClientConfig <AmazonAutoScalingConfig>
Amazon.PowerShell.Cmdlets.AS.AmazonAutoScalingClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Cooldown <Int32>
A cooldown period, in seconds, that applies to a specific simple scaling policy. 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
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-CustomizedMetricSpecification_Dimension <MetricDimension[]>
The dimensions of the metric.Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Dimensions
-CustomizedMetricSpecification_Metric <TargetTrackingMetricDataQuery[]>
The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Metrics
-CustomizedMetricSpecification_MetricName <String>
The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_MetricName
-CustomizedMetricSpecification_Namespace <String>
The namespace of the metric.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Namespace
-CustomizedMetricSpecification_Statistic <MetricStatistic>
The statistic of the metric.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Statistic
-CustomizedMetricSpecification_Unit <String>
The unit of the metric. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Unit
-Enabled <Boolean>
Indicates whether the scaling policy is enabled or disabled. The default is enabled. For more information, see Disabling a scaling policy for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-EstimatedInstanceWarmup <Int32>
Not needed if the default instance warmup is defined for the group.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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-MetricAggregationType <String>
The aggregation type for the CloudWatch metrics. 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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-MinAdjustmentMagnitude <Int32>
The minimum value to scale by when the adjustment type is PercentChangeInCapacity. 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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-MinAdjustmentStep <Int32>
Available for backward compatibility. Use MinAdjustmentMagnitude instead.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PassThru <SwitchParameter>
Changes the cmdlet behavior to return the value passed to the AutoScalingGroupName parameter. The -PassThru parameter is deprecated, use -Select '^AutoScalingGroupName' instead. This parameter will be removed in a future version.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PolicyName <String>
The name of the policy.
Required?True
Position?2
Accept pipeline input?True (ByPropertyName)
-PolicyType <String>
One of the following policy types:
  • TargetTrackingScaling
  • StepScaling
  • SimpleScaling (default)
  • PredictiveScaling
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PredefinedMetricSpecification_PredefinedMetricType <MetricType>
The metric type. The following predefined metrics are available:
  • ASGAverageCPUUtilization - Average CPU utilization of the Auto Scaling group.
  • ASGAverageNetworkIn - Average number of bytes received on all network interfaces by the Auto Scaling group.
  • ASGAverageNetworkOut - Average number of bytes sent out on all network interfaces by the Auto Scaling group.
  • ALBRequestCountPerTarget - Average Application Load Balancer request count per target for your Auto Scaling group.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_PredefinedMetricSpecification_PredefinedMetricType
-PredefinedMetricSpecification_ResourceLabel <String>
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.Where:
  • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
  • targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_PredefinedMetricSpecification_ResourceLabel
-PredictiveScalingConfiguration_MaxCapacityBreachBehavior <PredictiveScalingMaxCapacityBreachBehavior>
Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity of the Auto Scaling group. Defaults to HonorMaxCapacity if not specified.The following are possible values:
  • HonorMaxCapacity - Amazon EC2 Auto Scaling cannot scale out capacity higher than the maximum capacity. The maximum capacity is enforced as a hard limit.
  • IncreaseMaxCapacity - Amazon EC2 Auto Scaling can scale out capacity higher than the maximum capacity when the forecast capacity is close to or exceeds the maximum capacity. The upper limit is determined by the forecasted capacity and the value for MaxCapacityBuffer.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PredictiveScalingConfiguration_MaxCapacityBuffer <Int32>
The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55.If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the maximum capacity to equal but not exceed forecast capacity. Required if the MaxCapacityBreachBehavior property is set to IncreaseMaxCapacity, and cannot be used otherwise.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PredictiveScalingConfiguration_MetricSpecification <PredictiveScalingMetricSpecification[]>
This structure includes the metrics and target utilization to use for predictive scaling.This is an array, but we currently only support a single metric specification. That is, you can specify a target value and a single metric pair, or a target value and one scaling metric and one load metric.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesPredictiveScalingConfiguration_MetricSpecifications
-PredictiveScalingConfiguration_Mode <PredictiveScalingMode>
The predictive scaling mode. Defaults to ForecastOnly if not specified.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PredictiveScalingConfiguration_SchedulingBufferTime <Int32>
The amount of time, in seconds, by which the instance launch time can be advanced. For example, the forecast says to add capacity at 10:00 AM, and you choose to pre-launch instances by 5 minutes. In that case, the instances will be launched at 9:55 AM. The intention is to give resources time to be provisioned. It can take a few minutes to launch an EC2 instance. The actual amount of time required depends on several factors, such as the size of the instance and whether there are startup scripts to complete.The value must be less than the forecast interval duration of 3600 seconds (60 minutes). Defaults to 300 seconds if not specified.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScalingAdjustment <Int32>
The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a non-negative value.Required if the policy type is SimpleScaling. (Not used with any other policy type.)
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Select <String>
Use the -Select parameter to control the cmdlet output. The default value is '*'. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.AutoScaling.Model.PutScalingPolicyResponse). Specifying the name of a property of type Amazon.AutoScaling.Model.PutScalingPolicyResponse will result in that property being returned. Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-StepAdjustment <StepAdjustment[]>
A set of adjustments that enable you to scale based on the size of the alarm breach.Required if the policy type is StepScaling. (Not used with any other policy type.)
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStepAdjustments
-TargetTrackingConfiguration_DisableScaleIn <Boolean>
Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is disabled, the target tracking scaling policy doesn't remove instances from the Auto Scaling group. Otherwise, the target tracking scaling policy can remove instances from the Auto Scaling group. The default is false.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-TargetTrackingConfiguration_TargetValue <Double>
The target value for the metric.Some metrics are based on a count instead of a percentage, such as the request count for an Application Load Balancer or the number of messages in an SQS queue. If the scaling policy specifies one of these metrics, specify the target utilization as the optimal average request or message count per instance during any one-minute interval.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet returns an Amazon.AutoScaling.Model.PutScalingPolicyResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Examples

Example 1

Write-ASScalingPolicy -AutoScalingGroupName my-asg -AdjustmentType "ChangeInCapacity" -PolicyName "myScaleInPolicy" -ScalingAdjustment -1

arn:aws:autoscaling:us-west-2:123456789012:scalingPolicy:aa3836ab-5462-42c7-adab-e1d769fc24ef:autoScalingGroupName/my-asg
:policyName/myScaleInPolicy
This example adds the specified policy to the specified Auto Scaling group. The specified adjustment type determines how to interpret the ScalingAdjustment parameter. With 'ChangeInCapacity', a positive value increases the capacity by the specified number of instances and a negative value decreases the capacity by the specified number of instances.

Supported Version

AWS Tools for PowerShell: 2.x.y.z