From c2047194f502f2cf149bf5e95197348b2dc1cef2 Mon Sep 17 00:00:00 2001 From: Rich Mogull Date: Thu, 24 May 2018 16:44:39 -0700 Subject: [PATCH] Account ID fix Altered call method so getting the account ID works with sts, which is needed for various authentication methods. --- count_resources.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/count_resources.py b/count_resources.py index b1169c4..c4c45eb 100644 --- a/count_resources.py +++ b/count_resources.py @@ -37,9 +37,10 @@ def controller(access, secret, profile): sys.exit() # pull the account ID for use when needed for filtering - iam = session.resource('iam') + iam = session.client('sts') - account_id = iam.CurrentUser().arn.split(':')[4] + # account_id = iam.CurrentUser().arn.split(':')[4] + account_id = iam.get_caller_identity()["Account"] click.echo('Current account ID: ' + account_id) # Initialize dictionary to hold the counts. Pull the regions using EC2, since that is in every region.