与 AWS SDK或DescribeScalingPolicies一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

与 AWS SDK或DescribeScalingPolicies一起使用 CLI

以下代码示例演示如何使用 DescribeScalingPolicies

CLI
AWS CLI

描述扩展策略

此示例命令描述了 ecs 服务命名空间的扩展策略。

命令:

aws application-autoscaling describe-scaling-policies --service-namespace ecs

输出:

{ "ScalingPolicies": [ { "PolicyName": "web-app-cpu-gt-75", "ScalableDimension": "ecs:service:DesiredCount", "ResourceId": "service/default/web-app", "CreationTime": 1462561899.23, "StepScalingPolicyConfiguration": { "Cooldown": 60, "StepAdjustments": [ { "ScalingAdjustment": 200, "MetricIntervalLowerBound": 0.0 } ], "AdjustmentType": "PercentChangeInCapacity" }, "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/web-app-cpu-gt-75", "PolicyType": "StepScaling", "Alarms": [ { "AlarmName": "web-app-cpu-gt-75", "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:web-app-cpu-gt-75" } ], "ServiceNamespace": "ecs" }, { "PolicyName": "web-app-cpu-lt-25", "ScalableDimension": "ecs:service:DesiredCount", "ResourceId": "service/default/web-app", "CreationTime": 1462562575.099, "StepScalingPolicyConfiguration": { "Cooldown": 1, "StepAdjustments": [ { "ScalingAdjustment": -50, "MetricIntervalUpperBound": 0.0 } ], "AdjustmentType": "PercentChangeInCapacity" }, "PolicyARN": "arn:aws:autoscaling:us-west-2:012345678910:scalingPolicy:6d8972f3-efc8-437c-92d1-6270f29a66e7:resource/ecs/service/default/web-app:policyName/web-app-cpu-lt-25", "PolicyType": "StepScaling", "Alarms": [ { "AlarmName": "web-app-cpu-lt-25", "AlarmARN": "arn:aws:cloudwatch:us-west-2:012345678910:alarm:web-app-cpu-lt-25" } ], "ServiceNamespace": "ecs" } ] }
PowerShell
用于 PowerShell

示例 1:此 cmdlet 描述了指定服务命名空间的 Application Auto Scaling 扩展策略。

Get-AASScalingPolicy -ServiceNamespace AppStream

输出:

Alarms : {Appstream2-LabFleet-default-scale-out-Alarm} CreationTime : 9/3/2019 2:48:15 AM PolicyARN : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet: policyName/default-scale-out PolicyName : default-scale-out PolicyType : StepScaling ResourceId : fleet/LabFleet ScalableDimension : appstream:fleet:DesiredCapacity ServiceNamespace : appstream StepScalingPolicyConfiguration : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration TargetTrackingScalingPolicyConfiguration : Alarms : {Appstream2-LabFleet-default-scale-in-Alarm} CreationTime : 9/3/2019 2:48:15 AM PolicyARN : arn:aws:autoscaling:us-west-2:012345678912:scalingPolicy:5659b069-b5cd-4af1-9f7f-3e956d36233e:resource/appstream/fleet/LabFleet: policyName/default-scale-in PolicyName : default-scale-in PolicyType : StepScaling ResourceId : fleet/LabFleet ScalableDimension : appstream:fleet:DesiredCapacity ServiceNamespace : appstream StepScalingPolicyConfiguration : Amazon.ApplicationAutoScaling.Model.StepScalingPolicyConfiguration TargetTrackingScalingPolicyConfiguration :
Rust
SDK对于 Rust
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

async fn show_policies(client: &Client) -> Result<(), Error> { let response = client .describe_scaling_policies() .service_namespace(ServiceNamespace::Ec2) .send() .await?; println!("Auto Scaling Policies:"); for policy in response.scaling_policies() { println!("{:?}\n", policy); } println!("Next token: {:?}", response.next_token()); Ok(()) }