From 40e1cb1822610b48071f5b2a041f400ebd2ca895 Mon Sep 17 00:00:00 2001 From: Christian PHU Date: Fri, 17 Mar 2023 17:14:33 +0100 Subject: [PATCH] Use arg to select aws session type (#1142) --- cartography/intel/aws/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cartography/intel/aws/__init__.py b/cartography/intel/aws/__init__.py index 8ae0ccdd8..dccf52a2e 100644 --- a/cartography/intel/aws/__init__.py +++ b/cartography/intel/aws/__init__.py @@ -144,6 +144,7 @@ def _sync_multiple_accounts( sync_tag: int, common_job_parameters: Dict[str, Any], aws_best_effort_mode: bool, + aws_sync_all_profiles: bool, aws_requested_syncs: List[str] = [], ) -> bool: logger.info("Syncing AWS accounts: %s", ', '.join(accounts.values())) @@ -152,16 +153,13 @@ def _sync_multiple_accounts( failed_account_ids = [] exception_tracebacks = [] - num_accounts = len(accounts) - for profile_name, account_id in accounts.items(): logger.info("Syncing AWS account with ID '%s' using configured profile '%s'.", account_id, profile_name) common_job_parameters["AWS_ID"] = account_id - if num_accounts == 1: - # Use the default boto3 session because boto3 gets confused if you give it a profile name with 1 account - boto3_session = boto3.Session() - else: + if aws_sync_all_profiles: boto3_session = boto3.Session(profile_name=profile_name) + else: + boto3_session = boto3.Session() _autodiscover_accounts(neo4j_session, boto3_session, account_id, sync_tag, common_job_parameters) @@ -301,6 +299,7 @@ def start_aws_ingestion(neo4j_session: neo4j.Session, config: Config) -> None: config.update_tag, common_job_parameters, config.aws_best_effort_mode, + config.aws_sync_all_profiles, requested_syncs, )