Lab build

Blog generator on Bedrock and Lambda

Serverless API that writes a 200-word blog post with Llama 2 on Bedrock and stores it in S3.

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

What it does

An AWS Lambda function receives a blog topic in the request body, prompts Meta Llama 2 13B Chat through the Bedrock runtime API and writes the generated text to an S3 bucket under a timestamped key. The function sits behind an API Gateway route and is exercised with Postman requests.

What was built

  1. 01

    Lambda handler parses blog_topic from the event body and builds an [INST]-formatted prompt.

  2. 02

    Bedrock invoke_model calls meta.llama2-13b-chat-v1 with 512 max tokens, temperature 0.5 and client retries.

  3. 03

    Generated text is saved to S3 as blog-output/<time>.txt and the handler returns status 200.

  4. 04

    API Gateway forwards POST requests to the function.

The pipeline, layer by layer

Four layers, one pipeline.

  1. L1Request

    • API Gateway POST
  2. L2Compute

    • AWS Lambda handler
  3. L3Model

    • Bedrock Llama 2 13B
  4. L4Storage

    • S3 blog output

Stack

  • AWS Lambda
  • Amazon Bedrock
  • Llama 2 13B Chat
  • boto3
  • Amazon S3
  • API Gateway
  • Postman

Next lab build · 11 / 46

Serverless image labelling with Rekognition and CDK

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

Previous: Falcon-40B on a SageMaker endpoint

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