Skip to content

SQS Quickstart

Event handler for Amazon SQS Events.

Features

  • Automatically convert JSON from message body
  • Automatically flatten message attributes
  • Able to message body against a JSON Schema
  • Assign Data Classes to records instead of getting record objects

Installation

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

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
from acai_aws.sqs.requirements import requirements

@requirements(
    required_body='v1-sqs-event'
)
def handle(event):
    for record in event.records:
        print(record)
1
2
3
4
5
6
7
8
9
functions:
    sqs-handler:
        handler: service/handlers/sqs.handle
        memorySize: 512
        timeout: 900
        events:
            - sqs:
                arn:
                    Fn::GetAtt: [ SomeQueue, 'Arn' ]