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.
- 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
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.
sam buildAnd then deploy your app to your account:
sam deployYou 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.jsonOf course, CloudWatch should capture this entire invocation too. Can read more about my experience building this here.