Skip to content

S3 Quickstart

Event handler for Amazon S3 Bucket Events.

Features

  • Automatically convert JSON files to JSON objects
  • Automatically convert CSV files to JSON objects
  • Only run on certain S3 operations, like on when items are created, updated or deleted
  • Able to validate S3 record against a JSON Schema
  • Assign Data Classes to records instead of getting raw S3 JSON objects

Installation

1
2
3
$ pip install acai_aws
# pipenv install acai_aws
# poetry add acai_aws

Minimal Setup

After installation, create a handler file and configure the AWS lambda to use that file as its handler.

1
2
3
4
5
6
7
8
9
from acai_aws.s3.requirements import requirements

@requirements(
    get_object=True,
    data_type='json'
)
def handle(event):
    for record in event.records:
        print(record)
1
2
3
4
5
6
7
8
9
functions:
    s3-handler:
        handler: service/handlers/s3.handle
        memorySize: 512
        timeout: 900
        events:
            - s3:
                bucket: uploadsBucket
                event: s3:ObjectCreated:*