awslabs / rds-snapshot-tool

The Snapshot Tool for Amazon RDS automates the task of creating manual snapshots, copying them into a different account and a different region, and deleting them after a specified number of days
Apache License 2.0
341 stars 144 forks source link

KeyError in get_own_snapshots_source() if a snapshot is in progress #45

Closed danielmklein closed 4 years ago

danielmklein commented 5 years ago

Similar to #38, it appears that we include in progress snapshots when parsing snapshots, which appears to be causing errors like this (since an in-progress snapshot does not have a Create Time): 'SnapshotCreateTime': KeyError Traceback (most recent call last): File "/var/task/lambda_function.py", line 49, in lambda_handler filtered_snapshots = get_own_snapshots_source(PATTERN, paginate_api_call(client, 'describe_db_snapshots', 'DBSnapshots'), BACKUP_INTERVAL) File "/var/task/snapshots_tool_utils.py", line 206, in get_own_snapshots_source if backup_interval and snapshot['SnapshotCreateTime'].replace(tzinfo=None) < datetime.utcnow().replace(tzinfo=None) - timedelta(hours=backup_interval): KeyError: 'SnapshotCreateTime'

I plan to submit a PR against this issue soon.

aaronbrashears commented 5 years ago

We are also running into this.