def wait_for_snapshot_validation(event, context):
"""
Gets the snapshots involved in the step function and checks for success
of the MongoDB validator script.
"""
session = boto3.session.Session(region_name=event.get("region"))
ec2 = session.resource("ec2")
snapshot_ids = [vol["snapshot-id"] for vol in event.get("backup-volumes")]
for sid in snapshot_ids:
tags = ec2.Snapshot(sid).tags
if not tags:
break
for tag in tags:
if tag.get("Key") == VALIDATION_TAG_KEY:
if tag.get("Success") == "false":
raise Exception("Validation failed!")
else:
return event
raise NotReady("Snapshot not validated yet.")
评论列表
文章目录