Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
标记 OpsItems
本节主题介绍如何在 OpsItems 文档上使用标签。
创建带标签的 OpsItems
如果您使用命令行工具,则可以在创建自定义 Amazon Systems Manager OpsItems 时向它们添加标签。
有关信息,请参阅以下主题:
向现有 OpsItems 添加标签
您可以使用命令行工具向 OpsItems 添加标签。
向现有 OpsItem 添加标签 (命令行)
将标签添加到现有 OpsItem (命令行)
-
使用首选命令行工具运行以下命令,以查看可标记的 OpsItem 的列表。
- Linux & macOS
-
aws ssm describe-ops-items
- Windows
-
aws ssm describe-ops-items
- PowerShell
-
Get-SSMOpsItemSummary
记下要标记的 OpsItem 的 ID。
-
运行以下命令,以标记 OpsItem。将每个示例资源占位符
替换为您自己的信息。
- Linux & macOS
-
aws ssm add-tags-to-resource \
--resource-type "OpsItem" \
--resource-id "ops-item-id
" \
--tags "Key=tag-key
,Value=tag-value
"
- Windows
-
aws ssm add-tags-to-resource ^
--resource-type "OpsItem" ^
--resource-id "ops-item-id
" ^
--tags "Key=tag-key
,Value=tag-value
"
- PowerShell
-
$tag = New-Object Amazon.SimpleSystemsManagement.Model.Tag
$tag.Key = "tag-key
"
$tag.Value = "tag-value
"
Add-SSMResourceTag `
-ResourceType "OpsItem" `
-ResourceId "ops-item-id
" `
-Tag $tag `
-Force
如果成功,则命令没有输出。
-
运行以下命令以验证 OpsItem 标签。
- Linux & macOS
-
aws ssm list-tags-for-resource \
--resource-type "OpsItem" \
--resource-id "ops-item-id
"
- Windows
-
aws ssm list-tags-for-resource ^
--resource-type "OpsItem" ^
--resource-id "ops-item-id
"
- PowerShell
-
Get-SSMResourceTag `
-ResourceType "OpsItem" `
-ResourceId "ops-item-id
"
从 Systems Manager 中删除标签 OpsItems
您可以使用命令行工具从 Systems Manager OpsItems 中删除标签。
从 OpsItems 中删除标签(命令行)
-
使用您的首选命令行工具,运行以下命令,以列出您账户中的 OpsItems。
- Linux & macOS
-
aws ssm describe-ops-items
- Windows
-
aws ssm describe-ops-items
- PowerShell
-
Get-SSMOpsItemSummary
记下要从中删除标签的 OpsItem 的名称。
-
运行以下命令以从 OpsItem 中删除标签。将每个示例资源占位符
替换为您自己的信息。
- Linux & macOS
-
aws ssm remove-tags-from-resource \
--resource-type "OpsItem" \
--resource-id "ops-item-id
" \
--tag-key "tag-key
"
- Windows
-
aws ssm remove-tags-from-resource ^
--resource-type "OpsItem" ^
--resource-id "ops-item-id
" ^
--tag-key "tag-key
"
- PowerShell
-
Remove-SSMResourceTag `
-ResourceId "ops-item-id
" `
-ResourceType "OpsItem" `
-TagKey "tag-key
" `
-Force
如果成功,则命令没有输出。
-
运行以下命令以验证 OpsItem 标签。
- Linux & macOS
-
aws ssm list-tags-for-resource \
--resource-type "OpsItem" \
--resource-id "ops-item-id
"
- Windows
-
aws ssm list-tags-for-resource ^
--resource-type "OpsItem" ^
--resource-id "ops-item-id
"
- PowerShell
-
Get-SSMResourceTag `
-ResourceType "OpsItem" `
-ResourceId "ops-item-id
"