Skip to content

Instantly share code, notes, and snippets.

@flannon
Created October 4, 2016 03:03
Show Gist options
  • Save flannon/5cda28e482339ea507eb94f3c55e2092 to your computer and use it in GitHub Desktop.
Save flannon/5cda28e482339ea507eb94f3c55e2092 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import boto3
def sts_info(event, context):
sts = boto3.client('sts')
caller_id = sts.get_caller_identity()
awsid = caller_id['Account']
http_header = caller_id['ResponseMetadata']['HTTPHeaders']
date = caller_id['ResponseMetadata']['HTTPHeaders']['date']
response_metadata = caller_id['ResponseMetadata']
arn = caller_id['Arn'].split(':')
awsid_from_arn = arn[4]
assumed_role = arn[5].split('/')
role = assumed_role[1]
print('caller_id: ', caller_id)
print('awsid: ', awsid)
print('http_header: ', http_header)
print('awsid_from_arn: ', awsid_from_arn)
print('arn: ', arn)
print('role: ', role)
print('date: ', date)
print('response_metadata: ', response_metadata)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment