Skip to content

Albertozhao/s3imagegenerator

S3 Image Generator

This SAM app demonstrates how to use AWS Lambda to make calls to Bedrock's Titan Image Generator G1, generate an image based on text input, upload those images into an S3 bucket, and log everything in CloudWatch.

Setup

  • AWS CLI installed and configured
  • AWS SAM CLI installed
  • Access to Bedrock Titan Image Generator G1 and permissions to create Lambda functions, API Gateway, and S3 buckets

1. Create a S3 Bucket

Create a S3 bucket where the generated images will be stored:

aws s3 mb s3://<YOUR_BUCKET_NAME> --region <YOUR_REGION>

Clone this repo and update the template.yaml and app.py with your S3 bucket.

2. Deploy your SAM app

sam build

And then deploy your app to your account:

sam deploy

3. Test by invoking the Lambda locally

You can run this CLI command to invoke the Lambda and check the generated response.json to see if an image was successfully made and stored:

aws lambda invoke \
--function-name <YOUR_FUNCTION_NAME> \
--payload '{"text":"Add image prompt here","seed":42}' \
response.json

Of course, CloudWatch should capture this entire invocation too. Can read more about my experience building this here.

About

Generate an image in Amazon Bedrock Titan Image Generator G1, log in CloudWatch, and store it in S3.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages