標記OpsItems - AWS Systems Manager

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

標記OpsItems

本節中的主題說明如何在 OpsItems 文件上使用標籤。

使用標籤建立 OpsItems

如果您使用命令列工具,可以在建立自訂 AWS Systems Manager OpsItems 時將標籤新增至其中。

如需相關資訊,請參閱下列主題:

將標籤新增至現有的 OpsItems

您可以使用命令列工具將標籤新增至 OpsItems。

將標籤新增至現有的 OpsItem (命令列)

若要將標籤新增至現有的 OpsItem (命令列)
  1. 使用您偏好的命令列工具,執行以下命令來檢視您可以標記的 OpsItem 清單。

    Linux & macOS
    aws ssm describe-ops-items
    Windows
    aws ssm describe-ops-items
    PowerShell
    Get-SSMOpsItemSummary

    記下您想要標記之 OpsItem 的 ID。

  2. 執行以下命令來標記 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

    如果成功,命令不會有輸出。

  3. 執行以下命令來驗證 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 (命令列) 移除標籤

  1. 使用您偏好的命令列工具,執行以下命令來列出您帳戶中的 OpsItems。

    Linux & macOS
    aws ssm describe-ops-items
    Windows
    aws ssm describe-ops-items
    PowerShell
    Get-SSMOpsItemSummary

    記下您要從中移除標籤的 OpsItem 名稱。

  2. 執行以下命令,從 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

    如果成功,命令不會有輸出。

  3. 執行以下命令來驗證 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"