Infrastructure

Celery Cloud needs five AWS pieces. This section explains what each one is for and how to create it, in the order you should create them.

        graph LR
    App["Your application<br/>(Celery client)"]
    Q["SQS queue"]
    DLQ["Dead-letter queue"]
    F["Runner<br/>(Lambda, container image)"]
    T["DynamoDB table"]
    R["Remote Lambda<br/>(optional)"]
    ECR["ECR repository"]

    App -- "SendMessage" --> Q
    Q -- "event source mapping" --> F
    Q -. "after N failed receives" .-> DLQ
    ECR -- "image" --> F
    F -- "PutItem / UpdateItem" --> T
    F -- "InvokeFunction" --> R
    App -- "GetItem" --> T
    

Piece

Role

Guide

SQS queue (+ dead-letter queue)

The Celery broker: where the client leaves the tasks

SQS queue

DynamoDB table

The Celery result backend: states and results

DynamoDB table

IAM roles

Permissions of the runner and of the client

IAM roles and permissions

ECR repository + image

The container image of the runner (your tasks included)

Runner image (ECR)

Lambda function + event source mapping

The runner itself, wired to the queue

Lambda function and event source

Conventions of the guides

The guides use the AWS CLI (v2) and these values; replace them with yours:

export AWS_REGION=eu-central-1
export ACCOUNT_ID=123456789012
export QUEUE=lambda-runner-queue
export TABLE=lambda-runner-tasks
export FUNCTION=celery-cloud-runner

Note

All the pieces must be in the same Region: the Lambda image has to be in an ECR repository of the Region of the function, and the client, queue and table are configured with that Region.

Tip

The same resources are available as Terraform code: see Terraform.

Note

The commands follow the AWS documentation but have not been run against a real account while writing this guide. Read the output of each step; the tools (Terraform, CloudFormation, CDK, SAM) can express exactly the same resources if you prefer infrastructure as code.