Gunakan DescribeScalingPolicies dengan AWS SDK atau CLI - AWS SDKContoh Kode

Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan DescribeScalingPolicies dengan AWS SDK atau CLI

Contoh kode berikut menunjukkan cara menggunakanDescribeScalingPolicies.

CLI
AWS CLI

Untuk menggambarkan kebijakan penskalaan

Perintah contoh ini menjelaskan kebijakan penskalaan untuk namespace layanan ecs.

Perintah:

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

Output:

{ "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
Alat untuk PowerShell

Contoh 1: Cmdlet ini menjelaskan kebijakan penskalaan Application Auto Scaling untuk namespace layanan yang ditentukan.

Get-AASScalingPolicy -ServiceNamespace AppStream

Output:

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
SDKuntuk Rust
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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(()) }