Tagging managed nodes - Amazon Systems Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Tagging managed nodes

The topics in this section describe how to work with tags on managed nodes.

A managed node is any machine configured for Amazon Systems Manager. This includes Amazon Elastic Compute Cloud (Amazon EC2) instances, edge devices, and on-premises servers or virtual machines (VMs) in a hybrid environment that are configured for Systems Manager.

The instructions in this topic are applicable to any machine that is managed using Systems Manager.

Creating or activating managed nodes with tags

You can add tags to EC2 instances at the time you create them. You can add tags to on-premises servers and virtual machines (VMs) at the time you activate them.

For information, see the following topics:

Adding tags to existing managed nodes

You can add tags to managed nodes by using the Systems Manager console or the command line.

Adding tags to an existing managed node (console)

  1. Open the Amazon Systems Manager console at https://console.amazonaws.cn/systems-manager/.

  2. In the navigation pane, choose Fleet Manager.

    -or-

    If the Amazon Systems Manager home page opens first, choose the menu icon ( ) to open the navigation pane, and then choose Fleet Manager in the navigation pane.

  3. Choose the ID of the managed node to add tags to, and then choose the Tags tab.

    Note

    If a managed node you expect to see isn't listed, see Troubleshooting managed node availability for troubleshooting tips.

  4. In the Tags section, choose Edit, and then add one or more key-value tag pairs.

  5. Choose Save.

Adding tags to an existing managed node (command line)

To add tags to an existing managed node (command line)

  1. Using your preferred command line tool, run the following command to view the list of managed nodes that you can tag.

    Linux & macOS
    aws ssm describe-instance-information
    Windows
    aws ssm describe-instance-information
    PowerShell
    Get-SSMInstanceInformation

    Note the ID of a managed node that you want to tag.

    Note

    Machines that have been registered for use with Systems Manager in a hybrid environment begin with mi-, such as mi-0471e04240EXAMPLE. EC2 instances have IDs that begin with i-, such as i-02573cafcfEXAMPLE.

  2. Run the following command to tag a managed node.

    Linux & macOS
    aws ssm add-tags-to-resource \ --resource-type "ManagedInstance" \ --resource-id "instance-id" \ --tags "Key=tag-key,Value=tag-value"
    Windows
    aws ssm add-tags-to-resource ^ --resource-type "ManagedInstance" ^ --resource-id "instance-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 "ManagedInstance" ` -ResourceId "instance-id" ` -Tag $tag ` -Force

    tag-key is the name of a custom key you supply. For example, Region or Quarter.

    tag-value is the custom content for the value you want to supply for that key. For example, West or Q321.

    instance-id is the ID of the managed node you want to tag.

    If successful, the command has no output.

  3. Run the following command to verify the managed node tags.

    Linux & macOS
    aws ssm list-tags-for-resource \ --resource-type "ManagedInstance" \ --resource-id "instance-id"
    Windows
    aws ssm list-tags-for-resource ^ --resource-type "ManagedInstance" ^ --resource-id "instance-id"
    PowerShell
    Get-SSMResourceTag ` -ResourceType "ManagedInstance" ` -ResourceId "instance-id"

Removing tags from managed nodes

You can use the Systems Manager console or the command line to remove tags from managed nodes.

Removing tags from managed nodes (console)

  1. Open the Amazon Systems Manager console at https://console.amazonaws.cn/systems-manager/.

  2. In the navigation pane, choose Fleet Manager.

    -or-

    If the Amazon Systems Manager home page opens first, choose the menu icon ( ) to open the navigation pane, and then choose Fleet Manager in the navigation pane.

  3. Choose the name of the managed node to remove tags from, and then choose the Tags tab.

  4. In the Tags section, choose Edit, and then choose Remove next to the tag pair you no longer need.

  5. Choose Save.

Removing tags from managed nodes (command line)

  1. Using your preferred command line tool, run the following command to list the managed nodes in your account.

    Linux & macOS
    aws ssm describe-instance-information
    Windows
    aws ssm describe-instance-information
    PowerShell
    Get-SSMInstanceInformation

    Note the name of a managed node from which you want to remove tags.

  2. Run the following command to remove tags from a managed node.

    Linux & macOS
    aws ssm remove-tags-from-resource \ --resource-type "ManagedInstance" \ --resource-id "instance-id" \ --tag-key "tag-key"
    Windows
    aws ssm remove-tags-from-resource ^ --resource-type "ManagedInstance" ^ --resource-id "instance-id" ^ --tag-key "tag-key"
    PowerShell
    Remove-SSMResourceTag ` -ResourceId "instance-id" ` -ResourceType "ManagedInstance" ` -TagKey "tag-key" ` -Force

    instance-id is the name of the managed node from which you want to remove tags.

    tag-key is the name of a key assigned to the managed node. For example, Environment or Quarter.

    If successful, the command has no output.

  3. Run the following command to verify the managed node tags.

    Linux & macOS
    aws ssm list-tags-for-resource \ --resource-type "ManagedInstance" \ --resource-id "instance-id"
    Windows
    aws ssm list-tags-for-resource ^ --resource-type "ManagedInstance" ^ --resource-id "instance-id"
    PowerShell
    Get-SSMResourceTag ` -ResourceType "ManagedInstance" ` -ResourceId "instance-id"