From ca2a0e29fbc46c3a2f5bcc7842cc51399c2ff83c Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Wed, 13 May 2020 11:44:28 -0700 Subject: [PATCH 1/2] Passes profile and region through the refreshable credential properly --- security_hub_accepter.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/security_hub_accepter.py b/security_hub_accepter.py index 17e1f4f..8a378ef 100644 --- a/security_hub_accepter.py +++ b/security_hub_accepter.py @@ -59,7 +59,12 @@ def filter_none_values(data): def assume_role( - session, role_arn, duration=3600, session_name=None, serial_number=None + session, + role_arn, + profile=None, + duration=3600, + session_name=None, + serial_number=None, ): fetcher = botocore.credentials.AssumeRoleCredentialFetcher( session.create_client, @@ -74,7 +79,7 @@ def assume_role( ), cache=botocore.credentials.JSONFileCache(), ) - role_session = botocore.session.Session() + role_session = botocore.session.Session(profile=profile) role_session.register_component( "credential_provider", botocore.credentials.CredentialResolver([AssumeRoleProvider(fetcher)]), @@ -106,8 +111,10 @@ def main( role_arn = role_arn or None session = botocore.session.Session(profile=profile) + session.set_default_client_config(botocore.client.Config(region_name=region)) + if role_arn: - session = assume_role(session, role_arn) + session = assume_role(session, role_arn, profile=profile) sechub = session.create_client("securityhub", region_name=region) From 0324f3c221ebda00d57643e213e5fefb3c2a5ed4 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Wed, 13 May 2020 12:26:16 -0700 Subject: [PATCH 2/2] Bumps version to 0.0.2 --- .bumpversion.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 40343da..60e4538 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,6 +1,7 @@ [bumpversion] -current_version = 0.0.1 +current_version = 0.0.2 commit = True message = Bumps version to {new_version} tag = False tag_name = {new_version} +