From d7da4e7759eabdf479bd9ddb0d96c8b6f8407499 Mon Sep 17 00:00:00 2001 From: carnal0wnage Date: Mon, 31 Jul 2017 16:24:27 -0400 Subject: [PATCH] sts updates --- libs/sts.py | 14 ++++++++++++++ sts_get_account_id.py | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 sts_get_account_id.py diff --git a/libs/sts.py b/libs/sts.py index faa7b1a..5b29315 100644 --- a/libs/sts.py +++ b/libs/sts.py @@ -15,4 +15,18 @@ def get_accountid(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): except KeyboardInterrupt: print("CTRL-C received, exiting...") + return account_id + +def get_accountid_all(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): + try: + client = boto3.client("sts", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY) + account_id = client.get_caller_identity()["Account"] + account_userid = client.get_caller_identity()["UserId"] + account_arn = client.get_caller_identity()["Arn"] + print("Account Id: {}" .format(account_id)) + print("Account UserID: {}" .format(account_userid) ) + print("Account ARN: {}" .format(account_arn) ) + except KeyboardInterrupt: + print("CTRL-C received, exiting...") + return account_id \ No newline at end of file diff --git a/sts_get_account_id.py b/sts_get_account_id.py new file mode 100644 index 0000000..487ac53 --- /dev/null +++ b/sts_get_account_id.py @@ -0,0 +1,8 @@ +''' +This file is used to perform some EMR actions +''' +from libs.sts import * +from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY + +get_accountid(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) +get_accountid_all(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) \ No newline at end of file