How aws-samples/amazon-bedrock-flows-samples works
Project Type and Purpose
• This is an open-source sample utility and demonstration repository for Amazon Bedrock Flows.
• It provides a Python CLI/Jupyter-based “Flow Manager” that:
– imports/creates Flow definitions from JSON templates
– invokes and tests those Flows against AWS Bedrock
– optionally cleans up (deletes) resources
• It also includes a CloudFormation template for deploying a Flow as an AWS resource.
File Structure
• Top-level
– README, CONTRIBUTING, LICENSE, requirements.txt, release notes, repo metadata
• cloudformation/
– bedrock_flows.json – CloudFormation template for automated Flow deployment
• docs/images/
• notebooks/
– flow_notebook.ipynb – interactive demonstration in Jupyter
• src/
– bedrock_flow_manager.py – main Python script (CLI + boto3 logic)
• templates/
– a set of JSON files implementing different Flow patterns (iterator, agents, RAG, guardrails, etc.)
README Insights
• The README outlines:
– the Flow patterns (nodes, connections, branching)
– CLI usage, arguments, and environment‐variable support
– CloudFormation deployment steps and parameters
– Examples for each template type
• It also references AWS IAM roles and permissions needed to manage Flows.
Main Components
a. Developer/Operator Environment
– Local CLI (bedrock_flow_manager.py)
– Local JSON templates directory
– Jupyter Notebook (flow_notebook.ipynb)
b. Infrastructure as Code
– CloudFormation service deploying bedrock_flows.json
c. AWS Services
– AWS IAM (executionRoleArn)
– Amazon Bedrock Flows Service
– (Optionally) Amazon S3 if DefinitionS3Location is used
d. Flow Execution Elements
– FlowDefinition (Nodes + Connections)
– Flow Versions, Flow Aliases
– Flow Invocation & Response
Relationships and Interactions
• CLI/Notebook reads a JSON template → calls boto3 to CreateFlow/CreateFlowVersion
→ AWS IAM evaluates permissions → Bedrock Flows Service stores the FlowDefinition
• CLI/Notebook invokes the Flow with test‐input → Bedrock runs each node
→ returns modelCompletion or aggregated array → CLI/Notebook collects outputs
• On --cleanup, CLI/Notebook calls DeleteFlowVersion/DeleteFlow → Bedrock deletes resources
• CloudFormation template can be deployed independently in AWS console/CLI to provision the same Flow
Architectural Patterns and Principles
• Separation of concerns
– “Flow Manager” logic (src/) vs JSON resources (templates/) vs IaC (cloudformation/)
• Extensibility points
– Add new JSON templates without changing code
– Plug in custom IAM roles via --existing-role
• Declarative vs Imperative
– Declarative (CloudFormation) vs Imperative (CLI/Notebook)
Including Relevant Technologies
• Python 3.10+, boto3, termcolor, rich
• Jupyter Notebook for interactive demos
• AWS CloudFormation
• AWS Bedrock Flows API
• JSON as the Flow definition language