This project demonstrates how to build a serverless blog generation system using AWS Bedrock (Meta Llama3-70B Instruct), AWS Lambda, API Gateway, and Amazon S3.
The application generates short blog posts based on a given topic and stores them in an S3 bucket.
- Uses AWS Bedrock to generate blog text with foundation models.
- Serverless execution using AWS Lambda.
- API exposure through API Gateway.
- Automatic blog storage in Amazon S3 with time-stamped filenames.
- Secure access management via IAM roles.
- Dependency packaging with Lambda layers (boto3).
Before you begin, ensure you have:
- An AWS account with permissions for Lambda, Bedrock, API Gateway, and S3.
- IAM credentials (Access Key & Secret).
- AWS CLI installed and configured:
aws configure
- Python 3.9 or later installed locally.
aws s3 mb s3://aws_bedrock_course1- Go to IAM Console → Create Role → Choose Lambda.
- Attach policies:
AmazonS3FullAccessAmazonBedrockFullAccessAWSLambdaBasicExecutionRole
- Save the Role ARN.
Package boto3 and botocore into a zip file:
pip install boto3 botocore -t python/
zip -r boto_layer.zip pythonUpload as a Lambda Layer in AWS Console.
- Go to AWS Lambda Console → Create Function.
- Choose Python runtime (e.g., Python 3.9).
- Attach the IAM role created above.
- Add the boto3 layer.
- Copy and paste the provided code into the Lambda editor.
- Go to API Gateway Console → Create API → HTTP API.
- Connect the Lambda function as integration.
- Deploy the API and note the Invoke URL.
Send a POST request with a blog topic:
curl -X POST "https://<api-id>.execute-api.<region>.amazonaws.com" -H "Content-Type: application/json" -d '{"blog_topic": "Water Pollution"}'The generated blog will be saved in your S3 bucket under blog-output/.
.
├── lambda_function.py # Main Lambda handler
├── requirements.txt # Dependencies (boto3, botocore)
└── README.md # Documentation
When sending:
{
"blog_topic": "Water Pollution"
}The system generates a 25-word blog about water pollution and stores it in:
s3://aws_bedrock_course1/blog-output/<timestamp>.txt
- IAM policies strictly limit access to Bedrock and S3 only.
- Lambda uses role-based execution, no hardcoded credentials.
This project combines AI-powered content generation with serverless cloud architecture to create a lightweight, cost-effective, and scalable solution for generating and storing blogs.