- Define the problem (difficulty processing existing data)
- Describe the solution pattern (S3 as input/output, Bedrock for inference)
- Show example code using the AWS SDK (boto3)
- Walk through a short demo (console view)
- Summarize next steps and expected outcomes


- Store source files in S3 (use buckets or prefixes to organize by team/use-case).
- Read objects from S3 in your application or serverless function.
- Send the file contents to Amazon Bedrock (invoke the chosen foundation model) for inference.
- Write generated outputs back to S3 (use a separate prefix or bucket for outputs).
- Optionally trigger the pipeline automatically using S3 Event Notifications (to Lambda, SQS, or SNS) for event-driven processing.

Code example (single-file, single-object)
This compact Python example uses boto3 to:
- Read a text object from S3
- Call the Bedrock runtime (invoke_model) with a chat-style messages payload
- Parse the model response (with flexible extraction to handle different model response shapes)
- Write the generated summary back to S3
modelId with values appropriate for your environment. Ensure your AWS credentials and region are configured (via environment variables, shared credentials file, or an IAM role).
- s3.get_object(…) reads the object from the specified S3 bucket/key and returns a streaming Body; the example reads and decodes it into a string.
- brt.invoke_model(…) sends a JSON payload to the Bedrock runtime. This includes chat-style
messagesand inference parameters such asmax_tokensandtemperature. - Models can return responses in different JSON shapes. The example includes multiple checks to extract the generated text; adjust extraction to match your model’s response format.
- s3.put_object(…) writes the generated summary back to S3. Use a dedicated output prefix (for example,
output/summary.txt) to keep inputs and outputs organized.
S3 terminology tip: files in S3 are called “objects” and are identified by object keys. Use logical prefixes such as
input/ and output/ (or separate buckets) to separate source data from generated results and simplify processing.input/ prefix, process each file, and write results under an output/ prefix. In production, add proper error handling, pagination, retries, rate limiting, and parallelization.
Production considerations: monitor and control model usage to avoid unexpected costs, add retries/backoff for transient errors, paginate
list_objects_v2 results, and ensure the IAM role or credentials used have least-privilege access to the relevant S3 buckets and Bedrock APIs.
- New object uploaded -> S3 Event Notification -> Lambda / SQS -> worker consumes message and calls Bedrock
- Or use a batch worker that polls SQS to process many files in parallel
- Retrieval-augmented generation (RAG) and semantic search (index embeddings for fast lookup)
- Preprocessing for binary formats (extract text from PDFs, Word documents, images with OCR)
- Robust orchestration (Step Functions, SQS, or containerized workers) for higher throughput and retry semantics
- Monitoring, billing alerts, and logging for model usage
- Amazon Bedrock overview: https://aws.amazon.com/bedrock/
- Amazon S3 documentation: https://docs.aws.amazon.com/s3/
- Boto3 documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
- S3 Event Notifications: https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-how-to.html
- AWS IAM best practices: https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html