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

Fix #821: Error while ingesting snapshots #822

Merged
merged 8 commits into from
Apr 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions cartography/intel/aws/ec2/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import boto3
import neo4j
from botocore.exceptions import ClientError

from cartography.util import aws_handle_regions
from cartography.util import run_cleanup_job
Expand Down Expand Up @@ -36,8 +37,16 @@ def get_snapshots(boto3_session: boto3.session.Session, region: str, in_use_snap
self_owned_snapshot_ids = {s['SnapshotId'] for s in snapshots}
other_snapshot_ids = set(in_use_snapshot_ids) - self_owned_snapshot_ids
if other_snapshot_ids:
for page in paginator.paginate(SnapshotIds=list(other_snapshot_ids)):
snapshots.extend(page['Snapshots'])
try:
for page in paginator.paginate(SnapshotIds=list(other_snapshot_ids)):
snapshots.extend(page['Snapshots'])
except ClientError as e:
if e.response['Error']['Code'] == 'InvalidSnapshot.NotFound':
logger.warning(f"Failed to retrieve page of in-use, \
not owned snapshots. Continuing anyway. Error - {e}")
else:
raise

return snapshots


Expand Down