Amazon S3 to Amazon Bedrock Batch Inference with Amazon EventBridge Trigger

Amazon S3 → Amazon EventBridge → AWS Lambda → Amazon Bedrock

Demonstrates automated Bedrock batch inference triggered by S3 file uploads, orchestrated via EventBridge rules. Implemented using AWS CDK.

This pattern creates an S3 bucket to store the input and output of the batch inference job.
It also creates an EventBridge rule that is triggered when a batch inference input file is uploaded.
When the EventBridge rule is triggered, it uses an AWS-managed Lambda function (created automatically by the AwsApi target) to call the Bedrock createModelInvocationJob API.
This Lambda function creates a new Bedrock batch inference job with the specified model and the uploaded input file.
The output of the batch inference job is stored in the same S3 bucket.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/s3-bedrock-batch-inference-cdk

Deploy

python3 -m venv .source ./bin/activatepip3 install -r requirements.txtexport AWS_REGION=us-west-2cdk deploy --parameters ModelARN=<ARN of the model>


Testing

Upload the sample input file: aws s3 cp model_input/input.jsonl s3://{S3 bucket name}/input/
Check batch inference job status: aws bedrock list-model-invocation-jobs | jq '.invocationJobSummaries[] | {jobArn, status, submitTime}'
Once completed (30+ minutes), check results in S3 bucket under 'output' prefix

Cleanup

Empty the S3 bucket: aws s3 rm s3://{S3 bucket name} --recursive
Delete the stack: cdk destroy

Created by:

Biswanath Mukherjee

Biswanath Mukherjee

Sr. Solutions Architect working at AWS India.

Follow on LinkedIn

Rakshith Rao

Rakshith Rao

I am a Senior Solutions Architect at AWS and help our strategic customers build and operate their key workloads on AWS.

Follow on LinkedIn