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>
-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>
-Select <String>
-PassThru <SwitchParameter>
-Force <SwitchParameter>

Description

Creates or updates a scaling policy for an Auto Scaling group. To update an existing scaling policy, use the existing policy name and set the parameters to change. Any existing parameter not changed in an update to an existing policy is not changed in this update request. For more information about using scaling policies to scale your Auto Scaling group automatically, see Dynamic Scaling in the Amazon EC2 Auto Scaling User Guide.

Parameters

-AdjustmentType <String>
Specifies whether the ScalingAdjustment parameter is an absolute number or a percentage of the current capacity. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.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.
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)
-Cooldown <Int32>
The amount of time, in seconds, after a scaling activity completes before any further dynamic scaling activities can start. If this parameter is not specified, the default cooldown period for the group applies.Valid only if the policy type is SimpleScaling. For more information, see Scaling Cooldowns in the Amazon EC2 Auto Scaling User Guide.
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_MetricName <String>
The name of the metric.
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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_CustomizedMetricSpecification_Unit
-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.Valid only if the policy type is StepScaling or TargetTrackingScaling.
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 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 property replaces the MinAdjustmentStep property. 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 SimpleScaling or StepScaling.
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>
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?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 - Number of requests completed per target in an Application Load Balancer target group.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_PredefinedMetricSpecification_PredefinedMetricType
-PredefinedMetricSpecification_ResourceLabel <String>
Identifies the resource associated with the metric type. You can't specify a resource label unless the metric type is ALBRequestCountPerTarget and there is a target group attached to the Auto Scaling group.The format is 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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTargetTrackingConfiguration_PredefinedMetricSpecification_ResourceLabel
-ScalingAdjustment <Int32>
The amount by which a simple scaling policy scales the Auto Scaling group in response to an alarm breach. The adjustment is based on the value that you specified in the AdjustmentType parameter (either an absolute number or a percentage). A positive value adds to the current capacity and a negative value subtracts from the current capacity. For exact capacity, you must specify a positive value.Conditional: If you specify SimpleScaling for the policy type, you must specify this parameter. (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.Conditional: If you specify StepScaling for the policy type, you must specify this parameter. (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.
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)
Aliases AK
-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 (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. 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? True (ByPropertyName)
Aliases AWSProfilesLocation, 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)
Aliases AWSProfileName, StoredCredentials
-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 (ByPropertyName)
-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)
Aliases SecretAccessKey, SK
-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)
Aliases ST
-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? True (ByPropertyName)
Aliases RegionToCall
-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)

Inputs

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

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

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