AWS Sync: Try all AWS accounts, and raise Exception afterwards
See original GitHub issueTitle: 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:
- Created 2 years ago
- Reactions:2
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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 😃