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.
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
- 01
Lambda handler parses blog_topic from the event body and builds an [INST]-formatted prompt.
- 02
Bedrock invoke_model calls meta.llama2-13b-chat-v1 with 512 max tokens, temperature 0.5 and client retries.
- 03
Generated text is saved to S3 as blog-output/<time>.txt and the handler returns status 200.
- 04
API Gateway forwards POST requests to the function.
The pipeline, layer by layer
Four layers, one pipeline.
L1Request
- API Gateway POST
L2Compute
- AWS Lambda handler
L3Model
- Bedrock Llama 2 13B
L4Storage
- S3 blog output