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

Invokes the PutScalingPolicy operation against Auto Scaling.

Syntax

Write-ASScalingPolicy
-AutoScalingGroupName <String>
-PolicyName <String>
-AdjustmentType <String>
-Cooldown <Int32>
-CustomizedMetricSpecification_Dimension <MetricDimension[]>
-TargetTrackingConfiguration_DisableScaleIn <Boolean>
-EstimatedInstanceWarmup <Int32>
-MetricAggregationType <String>
-CustomizedMetricSpecification_MetricName <String>
-MinAdjustmentMagnitude <Int32>
-MinAdjustmentStep <Int32>
-CustomizedMetricSpecification_Namespace <String>
-PolicyType <String>
-PredefinedMetricSpecification_PredefinedMetricType <MetricType>
-PredefinedMetricSpecification_ResourceLabel <String>
-ScalingAdjustment <Int32>
-CustomizedMetricSpecification_Statistic <MetricStatistic>
-StepAdjustment <StepAdjustment[]>
-TargetTrackingConfiguration_TargetValue <Double>
-CustomizedMetricSpecification_Unit <String>
-Force <SwitchParameter>

Description

Creates or updates a policy for an Auto Scaling group. To update an existing policy, use the existing policy name and set the parameters you want to change. Any existing parameter not changed in an update to an existing policy is not changed in this update request. If you exceed your maximum limit of step adjustments, which by default is 20 per region, the call fails. For information about updating this limit, see AWS Service Limits in the Amazon Web Services General Reference.

Parameters

-AdjustmentType <String>
The adjustment type. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.This parameter is supported if the policy type is SimpleScaling or StepScaling.For more information, see Dynamic Scaling in the Auto Scaling User Guide.
Required?False
Position?Named
Accept pipeline input?False
-AutoScalingGroupName <String>
The name or ARN of the group.
Required?False
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-Cooldown <Int32>
The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. If this parameter is not specified, the default cooldown period for the group applies.This parameter is supported if the policy type is SimpleScaling.For more information, see Auto Scaling Cooldowns in the Auto Scaling User Guide.
Required?False
Position?Named
Accept pipeline input?False
-CustomizedMetricSpecification_Dimension <MetricDimension[]>
The dimensions of the metric.
Required?False
Position?Named
Accept pipeline input?False
-CustomizedMetricSpecification_MetricName <String>
The name of the metric.
Required?False
Position?Named
Accept pipeline input?False
-CustomizedMetricSpecification_Namespace <String>
The namespace of the metric.
Required?False
Position?Named
Accept pipeline input?False
-CustomizedMetricSpecification_Statistic <MetricStatistic>
The statistic of the metric.
Required?False
Position?Named
Accept pipeline input?False
-CustomizedMetricSpecification_Unit <String>
The unit of the metric.
Required?False
Position?Named
Accept pipeline input?False
-EstimatedInstanceWarmup <Int32>
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. The default is to use the value specified for the default cooldown period for the group.This parameter is supported if the policy type is StepScaling or TargetTrackingScaling.
Required?False
Position?Named
Accept pipeline input?False
-Force <SwitchParameter>
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?False
-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.This parameter is supported if the policy type is StepScaling.
Required?False
Position?Named
Accept pipeline input?False
-MinAdjustmentMagnitude <Int32>
The minimum number of instances to scale. If the value of AdjustmentType is PercentChangeInCapacity, the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least this many instances. Otherwise, the error is ValidationError.This parameter is supported if the policy type is SimpleScaling or StepScaling.
Required?False
Position?Named
Accept pipeline input?False
-MinAdjustmentStep <Int32>
Available for backward compatibility. Use MinAdjustmentMagnitude instead.
Required?False
Position?Named
Accept pipeline input?False
-PolicyName <String>
The name of the policy.
Required?False
Position?2
Accept pipeline input?True (ByPropertyName)
-PolicyType <String>
The policy type. The valid values are SimpleScaling, StepScaling, and TargetTrackingScaling. If the policy type is null, the value is treated as SimpleScaling.
Required?False
Position?Named
Accept pipeline input?False
-PredefinedMetricSpecification_PredefinedMetricType <MetricType>
The metric type.
Required?False
Position?Named
Accept pipeline input?False
-PredefinedMetricSpecification_ResourceLabel <String>
Identifies the resource associated with 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 - number of requests completed per target in an Application Load Balancer target group
For predefined metric types ASGAverageCPUUtilization, ASGAverageNetworkIn and ASGAverageNetworkOut, the parameter must not be specified as the resource associated with the metric type is the Auto Scaling group. For predefined metric type ALBRequestCountPerTarget, the parameter must be specified in the format: app/load-balancer-name/load-balancer-id/targetgroup/target-group-name/target-group-id, where app/load-balancer-name/load-balancer-id is the final portion of the load balancer ARN, and targetgroup/target-group-name/target-group-id is the final portion of the target group ARN. The target group must be attached to the Auto Scaling group.
Required?False
Position?Named
Accept pipeline input?False
-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.This parameter is required if the policy type is SimpleScaling and not supported otherwise.
Required?False
Position?Named
Accept pipeline input?False
-StepAdjustment <StepAdjustment[]>
A set of adjustments that enable you to scale based on the size of the alarm breach.This parameter is required if the policy type is StepScaling and not supported otherwise.
Required?False
Position?Named
Accept pipeline input?False
-TargetTrackingConfiguration_DisableScaleIn <Boolean>
Indicates whether scale in by the target tracking policy is disabled. If the value is true, scale in is disabled and the target tracking policy won't remove instances from the Auto Scaling group. Otherwise, scale in is enabled and the target tracking policy can remove instances from the Auto Scaling group. The default value is false.
Required?False
Position?Named
Accept pipeline input?False
-TargetTrackingConfiguration_TargetValue <Double>
The target value for the metric.
Required?False
Position?Named
Accept pipeline input?False

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? False
-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? False
-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. Note that the encrypted credential file is not supported on all platforms. It will be skipped when searching for profiles on Windows Nano Server, Mac, and Linux platforms.

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? False
-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? False
-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? False
-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? False
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required? False
Position? Named
Accept pipeline input? False
-Region <String>
The system name of the AWS region in which the operation should be invoked. For example, us-east-1, eu-west-1 etc.
Required? False
Position? Named
Accept pipeline input? False
-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? False

Inputs

You can pipe a String object to this cmdlet for the AutoScalingGroupName parameter.

Outputs

This cmdlet returns a 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

PS C:\> 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