@@ -0,0 +1,1647 @@
+import sys%0Aimport time%0Aimport traceback%0Aimport boto3%0A%0AREGION = 'us-west-2'%0A%0As3 = boto3.client('s3')%0AS3_BUCKET_NAME = 'turbo-carnival'%0A%0Asns = boto3.client('sns', region_name=REGION)%0ASNS_ARN = 'arn:aws:sns:us-west-2:767736770298:turbo-carnival-process-replay'%0A%0Adef getListOfReplays(nextToken=None):%0A    replays = %5B%5D%0A    resp = None%0A    try:%0A        if nextToken:%0A            resp = s3.list_objects_v2(Bucket=S3_BUCKET_NAME, Prefix='replays', ContinuationToken=nextToken)%0A        else:%0A            resp = s3.list_objects_v2(Bucket=S3_BUCKET_NAME, Prefix='replays')%0A    except:%0A        traceback.print_exc(file=sys.stderr)%0A    %0A    if resp:%0A        for item in resp%5B'Contents'%5D:%0A            name = item%5B'Key'%5D.replace(%22replays/%22,%22%22).replace(%22.replay%22,%22%22)%0A            replays.append(name)%0A        truncated = resp%5B'IsTruncated'%5D%0A        if truncated:%0A            nextToken = resp%5B'NextContinuationToken'%5D%0A            print(%22Continuation: %22 + nextToken)%0A            more_replays = getListOfReplays(nextToken=nextToken)%0A            for replay in more_replays:%0A                replays.append(replay)%0A    return replays%0A%0Adef sendReplaySNS(replay):%0A    # Trigger replay to be processed%0A    print(%22Trigger replay processing %22 + replay)%0A    try:%0A        print(sns.publish(TopicArn=SNS_ARN, Subject='replay', Message=replay))%0A    except:%0A        traceback.print_exc(file=sys.stderr)%0A%0Areplays = getListOfReplays()%0A%0Ai = 0%0Afor replay in replays:%0A    sendReplaySNS(replay)%0A    i = i+1%0A    # 60 writes per second with 1 dynamo write capacity unit, say 6 writes per replay%0A    # Wait 1 second per 10 replays    %0A    if i%2510 == 0:%0A        time.sleep(1)%0A        break%0A

Create reprocess all script