Skip to content

gauthiii/blogGeneratorAWS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Blog Generator with AWS Bedrock & Lambda

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.


🚀 Features

  • 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).

🛠️ Prerequisites

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.

📦 Setup Steps

1. Create an S3 Bucket

aws s3 mb s3://aws_bedrock_course1

2. Create an IAM Role for Lambda

  • Go to IAM Console → Create Role → Choose Lambda.
  • Attach policies:
    • AmazonS3FullAccess
    • AmazonBedrockFullAccess
    • AWSLambdaBasicExecutionRole
  • Save the Role ARN.

3. Prepare Lambda Layer (boto3 & botocore)

Package boto3 and botocore into a zip file:

pip install boto3 botocore -t python/
zip -r boto_layer.zip python

Upload as a Lambda Layer in AWS Console.

4. Create Lambda Function

  • 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.

5. Deploy API Gateway

  • Go to API Gateway Console → Create API → HTTP API.
  • Connect the Lambda function as integration.
  • Deploy the API and note the Invoke URL.

6. Test the API

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/.


📂 Project Structure

.
├── lambda_function.py   # Main Lambda handler
├── requirements.txt     # Dependencies (boto3, botocore)
└── README.md            # Documentation

✅ Example Output

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

🔒 Security

  • IAM policies strictly limit access to Bedrock and S3 only.
  • Lambda uses role-based execution, no hardcoded credentials.

📝 Conclusion

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.

About

Serverless Blog Generator with AWS Bedrock & Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages