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>
-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. For more information about using scaling policies to scale your Auto Scaling group, see Target Tracking Scaling Policies and Step and Simple Scaling Policies in the Amazon EC2 Auto Scaling User Guide.

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)
-Cooldown <Int32>
The duration of the policy's cooldown period, in seconds. When a cooldown period is specified here, it overrides the default cooldown period defined for the Auto Scaling group.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.
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
-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>
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. If not provided, the default is to use the value from the default cooldown period for the Auto Scaling group.Valid only if the policy type is TargetTrackingScaling or StepScaling.
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)
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.Elastic Load Balancing sends data about your load balancers to Amazon CloudWatch. CloudWatch collects the data and specifies the format to use to access the data. 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.
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
-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 positive 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.
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

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