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