Bedrock Agent
This template demonstrates how to handle Amazon Bedrock Agent events using function-based actions.
Architecture
- Amazon Bedrock Agent receives user input.
- The Agent determines that a function call is needed based on the user's intent.
- The Agent invokes the AWS Lambda function with function details and parameters.
- The Lambda function processes the request using
BedrockAgentFunctionResolver. - Results are stored in and retrieved from a DynamoDB table.

Features
- Function-based Actions: Uses the
@app.tool()decorator to expose functions to Bedrock Agents. - Automatic Parameter Mapping: Maps Bedrock Agent parameters directly to Python function arguments.
- Type Safety: Uses Pydantic models for data validation and camelCase alias conversion.
- Observability: Integrated with AWS Lambda Powertools for logging, tracing, and metrics.
Usage
Define Tools
Use the @app.tool() decorator to define tools that the agent can call:
@app.tool(name="getItem", description="Gets item details by ID")
def get_item(item_id: str) -> dict:
return handler.get_item(item_id)
Infrastructure
Deploy the stack using:
make deploy STACK=agent
Code
- Function code:
templates/api - Unit tests:
tests/api - Infra stack:
infra/stacks/api.py
Item model
| Field | Type | Description |
|---|---|---|
id |
UUID string | Unique item identifier (auto-generated) |
name |
string | Human-readable item name |
description |
string | Human-readable item description |
Environment variables
| Variable | Description |
|---|---|
TABLE_NAME |
DynamoDB table name |
SERVICE_NAME |
Powertools service name |
METRICS_NAMESPACE |
Powertools metrics namespace |