Expand description
Decodes the AWS Account ID given an AWS Access Key ID (with a four-letter resource identifier beginning with “A”; this does not work for older key IDs beginning with “I” or “J”). There is also a function to return the resource type associated with a key ID prefix as helpful context.
§Example
use aws_account_id_from_key_id::*;
fn main() {
let access_key_id = "AKIASP2TPHJSQH3FJXYZ";
// Decode AWS account ID given AWS access key ID
assert_eq!(get_aws_account_id(&access_key_id).unwrap(), "171436882533");
// Get associated AWS resource type given AWS access key ID
assert_eq!(get_associated_resource_type(&access_key_id).unwrap(), "Access key");
}
§References / Credit
This is primarily based on the research and Python PoC code by Tal Be’ery.
Functions§
- get_
associated_ resource_ type - Get associated resource type given AWS key ID.
- get_
aws_ account_ id - Decodes the AWS account ID given an AWS access key ID.