To view public key tags
Use the describe-tags Amazon CLI command. In the following example, you
describe the tags for all of your public keys.
C:\>
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 specific public key
Use the describe-key-pairs Amazon CLI command.
C:\>
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 public key
Use the create-tags Amazon CLI command. In the following example, the
public key is tagged with Key=Cost-Center
and
Value=CC-123
.
C:\>
aws ec2 create-tags --resources key-0123456789EXAMPLE
--tags Key=Cost-Center
,Value=CC-123
To delete a tag from a public key
Use the delete-tags Amazon CLI command. For examples, see Examples in the Amazon CLI Command Reference.