Skip to content

Commit 2671337

Browse files
committed
fix: add docs
1 parent 2b4cf35 commit 2671337

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

docs/utilities/data_classes.md

+9
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Log Data Event for Troubleshooting
8585
| [AppSync Authorizer](#appsync-authorizer) | `AppSyncAuthorizerEvent` |
8686
| [AppSync Resolver](#appsync-resolver) | `AppSyncResolverEvent` |
8787
| [AWS Config Rule](#aws-config-rule) | `AWSConfigRuleEvent` |
88+
| [Bedrock Agent](#bedrock-agent) | `BedrockAgent` |
8889
| [CloudWatch Dashboard Custom Widget](#cloudwatch-dashboard-custom-widget) | `CloudWatchDashboardCustomWidgetEvent` |
8990
| [CloudWatch Logs](#cloudwatch-logs) | `CloudWatchLogsEvent` |
9091
| [CodePipeline Job Event](#codepipeline-job) | `CodePipelineJobEvent` |
@@ -484,6 +485,14 @@ In this example, we also use the new Logger `correlation_id` and built-in `corre
484485
--8<-- "examples/event_sources/src/aws_config_rule_scheduled.json"
485486
```
486487

488+
### Bedrock Agent
489+
490+
=== "app.py"
491+
492+
```python hl_lines="2 8 10"
493+
--8<-- "examples/event_sources/src/bedrock_agent_event.py"
494+
```
495+
487496
### CloudWatch Dashboard Custom Widget
488497

489498
=== "app.py"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from aws_lambda_powertools import Logger
2+
from aws_lambda_powertools.utilities.data_classes import BedrockAgentEvent, event_source
3+
from aws_lambda_powertools.utilities.typing import LambdaContext
4+
5+
logger = Logger()
6+
7+
8+
@event_source(data_class=BedrockAgentEvent)
9+
def lambda_handler(event: BedrockAgentEvent, context: LambdaContext) -> dict:
10+
input_text = event.input_text
11+
action = event.action_groups[0]
12+
13+
logger.info(f"Bedrock Agent {action.action_group} invoked with input", input_text=input_text)
14+
15+
return {
16+
"message_version": "1.0",
17+
"responses": [
18+
{
19+
"action_group": action.action_group,
20+
"api_path": action.api_path,
21+
"http_method": action.http_method,
22+
"http_status_code": 200,
23+
"response_body": {"application/json": {"body": "This is the response"}},
24+
},
25+
],
26+
}

0 commit comments

Comments
 (0)