文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
将 DeleteTags
与 CLI 配合使用
以下代码示例演示如何使用 DeleteTags
。
- CLI
-
- AWS CLI
-
从自动扩缩组中删除标签
此示例从指定的自动扩缩组删除指定的标签。
aws autoscaling delete-tags \ --tags
ResourceId=my-asg,ResourceType=auto-scaling-group,Key=Dept,Value=Research
此命令不生成任何输出。
有关更多信息,请参阅 Amazon Auto Scaling 用户指南中的为 A EC2 uto Scaling 组和实例添加标签。
-
有关 API 的详细信息,请参阅AWS CLI 命令参考DeleteTags
中的。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:此示例从指定的自动扩缩组删除指定的标签。在操作继续之前,系统会提示您进行确认。此示例使用的语法需要 PowerShell 版本 3 或更高版本。
Remove-ASTag -Tag @( @{ResourceType="auto-scaling-group"; ResourceId="my-asg"; Key="myTag" } )
输出:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-ASTag (DeleteTags)" on target "Amazon.AutoScaling.Model.Tag". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
示例 2:如果您指定 Force 参数,则在操作继续之前,系统不会提示您进行确认。
Remove-ASTag -Tag @( @{ResourceType="auto-scaling-group"; ResourceId="my-asg"; Key="myTag" } ) -Force
示例 3:对于 Powershell 版本 2,必须使用 New-Object 创建 Tag 参数的标签。
$tag = New-Object Amazon.AutoScaling.Model.Tag $tag.ResourceType = "auto-scaling-group" $tag.ResourceId = "my-asg" $tag.Key = "myTag" Remove-ASTag -Tag $tag -Force
-
有关 API 的详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考DeleteTags中的。
-
DeleteScheduledAction
DescribeAccountLimits