Lab build

Serverless image labelling with Rekognition and CDK

S3 uploads trigger a Lambda that labels images with Rekognition and stores labels in DynamoDB.

Role
Builder, end to end
Group
LLMOps and AIOps
Services
AI & LLM systems · MLOps & cloud

What it does

An AWS CDK stack in JavaScript defines an S3 image bucket, an IAM role, a DynamoDB table keyed on image name and a Python Lambda function. Each object-created event in the bucket invokes the function, which calls Rekognition detect_labels and writes up to ten labels above 60 percent confidence as attributes on the image's DynamoDB item. The stack is bootstrapped, synthesised to CloudFormation, deployed and destroyed with the CDK CLI.

What was built

  1. 01

    CDK stack creates the S3 bucket, DynamoDB table, IAM role and Python 3.9 Lambda with table and bucket environment variables.

  2. 02

    S3EventSource wires OBJECT_CREATED events on the bucket to the Lambda function.

  3. 03

    Lambda calls Rekognition detect_labels with MaxLabels 10 and MinConfidence 60.

  4. 04

    Each detected label is written to the image's DynamoDB item as object1, object2 and so on.

  5. 05

    cdk bootstrap, synth, deploy and destroy manage the full stack lifecycle.

The pipeline, layer by layer

Five layers, one pipeline.

  1. L1Infrastructure

    • AWS CDK stack
    • CloudFormation template
  2. L2Trigger

    • S3 image upload
    • Object-created event
  3. L3Compute

    • Python Lambda handler
  4. L4AI service

    • Rekognition detect_labels
  5. L5Storage

    • DynamoDB labels table

Stack

  • AWS CDK
  • JavaScript
  • AWS Lambda
  • Python
  • Amazon Rekognition
  • Amazon S3
  • Amazon DynamoDB
  • AWS IAM
  • AWS CloudFormation

Next lab build · 12 / 46

PDF RAG app on NVIDIA NIM

Answers questions over a folder of US census PDFs with NVIDIA embeddings, FAISS and Llama 3 70B.

Previous: Blog generator on Bedrock and Lambda

Need a system like this in production? Tell us about it.