Skip to content

Instantly share code, notes, and snippets.

@adamar
Created March 10, 2015 21:41
Show Gist options
  • Save adamar/1f2a0fba61b7976c4044 to your computer and use it in GitHub Desktop.
Save adamar/1f2a0fba61b7976c4044 to your computer and use it in GitHub Desktop.
View details of a set of AWS IAM Keys
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# This script takes a set of boto credential stored
# in a profile stanza and returns some account and user details
#
# [profile unknown]
# aws_access_key_id = AKIABLAHBLAH
# aws_secret_access_key = SUCHSECRETUUUUHHHHH
#
#
#
import boto.iam
import os
conn_iam = boto.iam.connect_to_region('universal', profile_name="unknown")
usr = conn_iam.get_user()
acc = conn_iam.get_account_alias()
print "User ID: " + str(usr.user_id)
print "User ARN: " + str(usr.arn)
print "User Credentials Last Used: " + str(usr.password_last_used)
print "User Creation Date: " + str(usr.create_date)
for item in acc.account_aliases:
print "Account Alias: " + str(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment