Python script to find an AWS IAM user by AWS ACCESS KEY ID
This sample project depends on boto, the AWS SDK for Python, and requires
Python 2.6.5+ or 2.7. You can install boto using pip
:
pip install boto
You need to set up your AWS security credentials before the sample code is able
to connect to AWS. You can do this by creating a file named "credentials" at ~/.aws/
(C:\Users\USER_NAME\.aws\
for Windows users) and saving the following lines in the file:
[default]
aws_access_key_id = <your access key id>
aws_secret_access_key = <your secret key>
See the Security Credentials page for more information on getting your keys.
python find_iam_user.py <SOME-ACCESS-KEY-ID-STRING>
- First establishes an IAM connection using the default AWS credentials on the system.
- Lists all users and searches for any with the provided AWS Access Key ID
- If no user is found with the AWS Access Key ID, attempts to establish a new IAM connection with the provided AWS Access Key ID and (prompted-for) AWS Secret Access Key. Information about the user can be provided if successful.