Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use arg to select aws session type (#1142) #1143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cartography/intel/aws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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)

Expand Down Expand Up @@ -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,
)

Expand Down
Loading