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

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

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

与 AWS SDK或DeregisterScalableTarget一起使用 CLI

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

CLI
AWS CLI

取消注册可扩展目标

此示例取消注册在默认集群中运行的名为 Web-app 的 Amazon ECS 服务的可扩展目标。

命令:

aws application-autoscaling deregister-scalable-target --service-namespace ecs --scalable-dimension ecs:service:DesiredCount --resource-id service/default/web-app

此示例取消注册自定义资源的可扩展目标。 custom-resource-id.txt 文件包含一个用于标识资源 ID 的字符串,对于自定义资源,该字符串是通过您的 Amazon API Gateway 终端节点指向自定义资源的路径。

命令:

aws application-autoscaling deregister-scalable-target --service-namespace custom-resource --scalable-dimension custom-resource:ResourceType:Property --resource-id file://~/custom-resource-id.txt

custom-resource-id.txt 文件的内容:

https://example.execute-api.us-west-2.amazonaws.com/prod/scalableTargetDimensions/1-23456789
PowerShell
用于 PowerShell

示例 1:此 cmdlet 注销 Application Auto Scaling 可扩展目标。取消注册可扩展目标会删除与其关联的扩展策略。

Remove-AASScalableTarget -ResourceId fleet/MyFleet -ScalableDimension appstream:fleet:DesiredCapacity -ServiceNamespace AppStream

输出:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-AASScalableTarget (DeregisterScalableTarget)" on target "fleet/MyFleet". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y