Whereas our speed layer is only interacting with DynamoDB, our batch layer will just be interacting with S3. There are two distinct types of functions in this layer—the functions that respond to S3 objects that arrive from Firehose, and functions that respond to S3 objects coming from Lambda functions. There isn't all that much difference, but it's important to point out the two different categories.
The following code block, taken from handler.py, shows the application code that comprises our batch layer:
def _get_bucket_and_key_from_event(event): record = event['Records'][0] s3 = record['s3'] bucket = s3['bucket']['name'] key = s3['object']['key'] return (bucket, key)def minute(event, context): """Process an S3 object uploaded ...