There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DescribePolicies with a CLI
The following code examples show how to use DescribePolicies.
- CLI
-
- AWS CLI
-
Example 1: To describe the scaling policies of a specified group
This example describes the scaling policies for the specified Auto Scaling group.
aws autoscaling describe-policies \ --auto-scaling-group-namemy-asgOutput:
{ "ScalingPolicies": [ { "AutoScalingGroupName": "my-asg", "PolicyName": "alb1000-target-tracking-scaling-policy", "PolicyARN": "arn:aws:autoscaling:us-west-2:123456789012:scalingPolicy:3065d9c8-9969-4bec-bb6a-3fbe5550fde6:autoScalingGroupName/my-asg:policyName/alb1000-target-tracking-scaling-policy", "PolicyType": "TargetTrackingScaling", "StepAdjustments": [], "Alarms": [ { "AlarmName": "TargetTracking-my-asg-AlarmHigh-924887a9-12d7-4e01-8686-6f844d13a196", "AlarmARN": "arn:aws:cloudwatch:us-west-2:123456789012:alarm:TargetTracking-my-asg-AlarmHigh-924887a9-12d7-4e01-8686-6f844d13a196" }, { "AlarmName": "TargetTracking-my-asg-AlarmLow-f96f899d-b8e7-4d09-a010-c1aaa35da296", "AlarmARN": "arn:aws:cloudwatch:us-west-2:123456789012:alarm:TargetTracking-my-asg-AlarmLow-f96f899d-b8e7-4d09-a010-c1aaa35da296" } ], "TargetTrackingConfiguration": { "PredefinedMetricSpecification": { "PredefinedMetricType": "ALBRequestCountPerTarget", "ResourceLabel": "app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff" }, "TargetValue": 1000.0, "DisableScaleIn": false }, "Enabled": true }, { "AutoScalingGroupName": "my-asg", "PolicyName": "cpu40-target-tracking-scaling-policy", "PolicyARN": "arn:aws:autoscaling:us-west-2:123456789012:scalingPolicy:5fd26f71-39d4-4690-82a9-b8515c45cdde:autoScalingGroupName/my-asg:policyName/cpu40-target-tracking-scaling-policy", "PolicyType": "TargetTrackingScaling", "StepAdjustments": [], "Alarms": [ { "AlarmName": "TargetTracking-my-asg-AlarmHigh-139f9789-37b9-42ad-bea5-b5b147d7f473", "AlarmARN": "arn:aws:cloudwatch:us-west-2:123456789012:alarm:TargetTracking-my-asg-AlarmHigh-139f9789-37b9-42ad-bea5-b5b147d7f473" }, { "AlarmName": "TargetTracking-my-asg-AlarmLow-bd681c67-fc18-4c56-8468-fb8e413009c9", "AlarmARN": "arn:aws:cloudwatch:us-west-2:123456789012:alarm:TargetTracking-my-asg-AlarmLow-bd681c67-fc18-4c56-8468-fb8e413009c9" } ], "TargetTrackingConfiguration": { "PredefinedMetricSpecification": { "PredefinedMetricType": "ASGAverageCPUUtilization" }, "TargetValue": 40.0, "DisableScaleIn": false }, "Enabled": true } ] }For more information, see Dynamic scaling in the Amazon EC2 Auto Scaling User Guide.
Example 2: To describe the scaling policies of a specified name
To return specific scaling policies, use the
--policy-namesoption.aws autoscaling describe-policies \ --auto-scaling-group-namemy-asg\ --policy-namescpu40-target-tracking-scaling-policySee example 1 for sample output.
For more information, see Dynamic scaling in the Amazon EC2 Auto Scaling User Guide.
Example 3: To describe a number of scaling policies
To return a specific number of policies, use the
--max-itemsoption.aws autoscaling describe-policies \ --auto-scaling-group-namemy-asg\ --max-items1See example 1 for sample output.
If the output includes a
NextTokenfield, use the value of this field with the--starting-tokenoption in a subsequent call to get the additional policies.aws autoscaling describe-policies --auto-scaling-group-namemy-asg--starting-tokenZ3M3LMPEXAMPLEFor more information, see Dynamic scaling in the Amazon EC2 Auto Scaling User Guide.
-
For API details, see DescribePolicies
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example describes all policies for the specified Auto Scaling group.
Get-ASPolicy -AutoScalingGroupName my-asgOutput:
AdjustmentType : ChangeInCapacity Alarms : {} AutoScalingGroupName : my-asg Cooldown : 0 EstimatedInstanceWarmup : 0 MetricAggregationType : MinAdjustmentMagnitude : 0 MinAdjustmentStep : 0 PolicyARN : arn:aws:auto-scaling:us-west-2:123456789012:scalingPolicy:aa3836ab-5462-42c7-adab-e1d769fc24ef :autoScalingGroupName/my-asg:policyName/myScaleInPolicy PolicyName : myScaleInPolicy PolicyType : SimpleScaling ScalingAdjustment : -1 StepAdjustments : {}Example 2: This example describes the specified policies for the specified Auto Scaling group.
Get-ASPolicy -AutoScalingGroupName my-asg -PolicyName @("myScaleOutPolicy", "myScaleInPolicy")Example 3: This example describes all policies for all your Auto Scaling groups.
Get-ASPolicy-
For API details, see DescribePolicies in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example describes all policies for the specified Auto Scaling group.
Get-ASPolicy -AutoScalingGroupName my-asgOutput:
AdjustmentType : ChangeInCapacity Alarms : {} AutoScalingGroupName : my-asg Cooldown : 0 EstimatedInstanceWarmup : 0 MetricAggregationType : MinAdjustmentMagnitude : 0 MinAdjustmentStep : 0 PolicyARN : arn:aws:auto-scaling:us-west-2:123456789012:scalingPolicy:aa3836ab-5462-42c7-adab-e1d769fc24ef :autoScalingGroupName/my-asg:policyName/myScaleInPolicy PolicyName : myScaleInPolicy PolicyType : SimpleScaling ScalingAdjustment : -1 StepAdjustments : {}Example 2: This example describes the specified policies for the specified Auto Scaling group.
Get-ASPolicy -AutoScalingGroupName my-asg -PolicyName @("myScaleOutPolicy", "myScaleInPolicy")Example 3: This example describes all policies for all your Auto Scaling groups.
Get-ASPolicy-
For API details, see DescribePolicies in AWS Tools for PowerShell Cmdlet Reference (V5).
-