DescribeKeypairs says that KeyPair can have tags, however it’s not possible to filter keys by tag or tag_key. Plus key pairs don’t have specific type ID, like i-*
, vol-*
and etc so tagging with CreateTags is also not possible. Creation via web not possible too.
All this seems very confusing because there is no way to create tag but it can be tagged 🤔
Is there a way to tag key pairs?
uhm...I haven't personally tried but using describe-key-pairs
in the AWS CLI should give you the key id.
However the only way I found to tag the key id is by using AWS CLI to generate it and have a look at the output.
If you use a simple command:
aws ec2 create-key-pair --key-name my-test-key --profile my-profile
Then the output has the key id.
{
"KeyFingerprint": "6d:5c:e0:19:de:.........",
"KeyMaterial": "......",
"KeyName": "my-test-key",
"KeyPairId": "key-0ab4ff01abc9999e"
}
Then you can tag the resource by using create-tags
that you already know.