Bare keys do not have "key IDs". They're just series of numbers.
If the key belongs to an X.509 certificate, then the certificate's fingerprint (a SHA-1 hash of the DER-encoded cert) will be used for identification:
openssl x509 -outform der | openssl sha1, or
openssl x509 -noout -fingerprint.
Otherwise (if it's just a bare public/private keypair), the SHA-1 hash of the public key is used sometimes (again, DER encoding), but I don't know of any standard for it. You can extract the public key with
openssl rsar -pubout -outform der, again piping to
openssl sha1 if that's what your program requires.
The "key pair IDs" used by CloudFront are serial numbers of the database entry with that key. The same key, uploaded twice, will have different IDs; I just tested it.