Tag a key pair - Amazon Elastic Compute Cloud
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 (PDF).

Tag a key pair

To help categorize and manage the key pairs that you've either created using Amazon EC2 or imported to Amazon EC2, you can tag them with custom metadata. For more information about how tags work, see Tag your Amazon EC2 resources.

Console
To view, add, or delete a tag for a key pair
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation pane, choose Key Pairs.

  3. Select a public key, and then choose Actions, Manage tags.

  4. The Manage tags page displays any tags that are assigned to the public key.

    • To add a tag, choose Add tag, and then enter the tag key and value. You can add up to 50 tags per key. For more information, see Tag restrictions.

    • To delete a tag, choose Remove next to the tag to delete.

  5. Choose Save.

Amazon CLI
To view the tags for your key pairs

Use the describe-tags Amazon CLI command. In the following example, you describe the tags for all of your public keys.

aws ec2 describe-tags --filters "Name=resource-type,Values=key-pair"
{ "Tags": [ { "Key": "Environment", "ResourceId": "key-0123456789EXAMPLE", "ResourceType": "key-pair", "Value": "Production" }, { "Key": "Environment", "ResourceId": "key-9876543210EXAMPLE", "ResourceType": "key-pair", "Value": "Production" }] }
To describe the tags for a key pair

Use the describe-key-pairs Amazon CLI command.

aws ec2 describe-key-pairs --key-pair-ids key-0123456789EXAMPLE
{ "KeyPairs": [ { "KeyName": "MyKeyPair", "KeyFingerprint": "1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", "KeyPairId": "key-0123456789EXAMPLE", "Tags": [ { "Key": "Environment", "Value": "Production" }] }] }
To tag a key pair

Use the create-tags Amazon CLI command. In the following example, the public key is tagged with Key=Cost-Center and Value=CC-123.

aws ec2 create-tags --resources key-0123456789EXAMPLE --tags Key=Cost-Center,Value=CC-123
To delete a tag from a key pair

Use the delete-tags Amazon CLI command. For examples, see Examples in the Amazon CLI Command Reference.

PowerShell
To view tags for your key pairs

Use the Get-EC2Tag command.

To describe the tags for a key pair

Use the Get-EC2KeyPair command.

To tag a key pair

Use the New-EC2Tag command.

To delete a tag from a key pair

Use the Remove-EC2Tag command.