本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
将 DeleteTags 与 CLI 配合使用
以下代码示例演示如何使用 DeleteTags。
- CLI
-
- Amazon CLI
-
从自动扩缩组中删除标签
此示例从指定的自动扩缩组删除指定的标签。
aws autoscaling delete-tags \ --tagsResourceId=my-asg,ResourceType=auto-scaling-group,Key=Dept,Value=Research此命令不生成任何输出。
有关更多信息,请参阅《Amazon EC2 Auto Scaling 用户指南》中的标记自动扩缩组和实例。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteTags
中的。
-
- PowerShell
-
- 适用于 PowerShell V4 的工具
-
示例 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 的详细信息,请参阅 Amazon Tools for PowerShell Cmdlet 参考 (V 4) DeleteTags中的。
-
- 适用于 PowerShell V5 的工具
-
示例 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 的详细信息,请参阅 Amazon Tools for PowerShell Cmdlet 参考 (V 5) DeleteTags中的。
-
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅将此服务与 Amazon SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。