question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS Sync: Try all AWS accounts, and raise Exception afterwards

See original GitHub issue

Title: Try all AWS accounts, and raise Exception afterwards

Description: Sometimes a single AWS account’s sync could fail. In such situations, we more likely want to proceed with the rest of our accounts, but still be notified of the failure.

I propose to wrap _sync_one_account into a try-catch, invoke logger.exception for the failures, and then finally raise another exception listing the accounts that failed.

https://github.com/lyft/cartography/blob/master/cartography/intel/aws/__init__.py#L145

For example:

failed_accont_ids = []
for account_id in account_ids:
    try:
        _sync_one_account(account_id)
    except Exception as e:
        logger.exception(e)
        failed_accont_ids.append(account_id)
if failed_accont_ids:
    raise Exception(f'Syncs failed for accounts {failed_accont_ids}')

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
achantavycommented, Mar 2, 2022

I agree on this approach and wanted to add that we should ensure that if there is an exception in one of the accounts, then execution stops and does not continue on to the cleanup jobs. We cannot have an exception in the get phase cause all data to be deleted.

0reactions
ryan-lanecommented, Apr 22, 2022

It’s worth mentioning that with SyncMetadata, it’s possible to determine if subsets of data are stale, so it’s a bit less painful to let that happen 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Handling - AWS Flow Framework for Java
Provides examples of error handling in AWS Flow Framework for Java. ... Unlike synchronous code, you can't use try/catch/finally in the calling code...
Read more >
Error handling and automatic retries in AWS Lambda
When you invoke a function, two types of error can occur. Invocation errors occur when the invocation request is rejected before your function...
Read more >
Error handling in Step Functions - AWS Documentation
A States.Runtime error isn't retriable, and will always cause the execution to fail. A retry or catch on States.ALL won't catch States.Runtime errors....
Read more >
Understanding return codes from the AWS CLI
To determine the return code of an AWS CLI command, run one of the following commands immediately after running the CLI command.
Read more >
sync — AWS CLI 1.27.35 Command Reference
The bucket mybucket contains the objects test.txt and test2.txt . The current local directory has no files: aws s3 sync s3:// ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found