Created
October 4, 2016 03:03
-
-
Save flannon/5cda28e482339ea507eb94f3c55e2092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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