Last active
June 30, 2022 00:10
-
-
Save achantavy/9ba7cb137d0167d16957a7c5950e93f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| boto3_session = boto3.Session(profile_name=profile_name) | |
| _autodiscover_accounts(neo4j_session, boto3_session, account_id, sync_tag, common_job_parameters) | |
| try: | |
| _sync_one_account( | |
| neo4j_session, | |
| boto3_session, | |
| account_id, | |
| sync_tag, | |
| common_job_parameters, | |
| aws_requested_syncs=aws_requested_syncs, # Could be replaced later with per-account requested syncs | |
| ) | |
| except Exception as e: | |
| if config.aws_best_effort_mode: | |
| timestamp = datetime.datetime.now() | |
| failed_account_ids.append(account_id) | |
| exception_traceback = traceback.TracebackException.from_exception(e) | |
| traceback_string = ''.join(exception_traceback.format()) | |
| exception_tracebacks.append(f'{timestamp} - Exception for account ID: {account_id}\n{traceback_string}') | |
| continue | |
| else: | |
| raise | |
| if failed_account_ids: | |
| logger.error(f'AWS sync failed for accounts {failed_account_ids}') | |
| message = '\n'.join(exception_tracebacks) | |
| raise Exception(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment