You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Amazon EventBridge Scheduler to Amazon Bedrock AI Agent
2
+
3
+
This pattern demonstrates how to trigger an Amazon Bedrock AI Agent on a recurring schedule using Amazon EventBridge Scheduler. An orchestrator AWS Lambda function, invoked by the scheduler, sends a task payload to the Bedrock Agent, which processes the input, generates an execution summary, and persists the result to a Amazon DynamoDB table via an action group Lambda.
4
+
5
+
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/eventbridge-scheduler-ai-agent-trigger
6
+
7
+
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
8
+
9
+
## Requirements
10
+
11
+
*[Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
12
+
*[AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured
1.**Amazon EventBridge Scheduler** – Triggers the orchestrator Lambda on a recurring schedule (default: `rate(1 hour)`).
23
+
2.**Orchestrator Lambda** (Python 3.14) – Receives the scheduler event and invokes the Bedrock Agent with a task payload.
24
+
3.**Amazon Bedrock Agent** – Processes the task payload, generates an execution summary using a foundation model (default: Claude 3 Haiku), and calls the action group.
25
+
4.**Action Group Lambda** (Python 3.14) – Persists execution records to DynamoDB.
26
+
5.**Amazon DynamoDB Table** – Stores task execution records.
27
+
6.**Amazon SQS Dead-Letter Queue** – Captures failed scheduler invocations after retries are exhausted.
cd serverless-patterns/eventbridge-scheduler-ai-agent-trigger
38
+
```
39
+
1. Initialize Terraform:
40
+
```
41
+
terraform init
42
+
```
43
+
1. Deploy the infrastructure:
44
+
```
45
+
terraform apply -auto-approve
46
+
```
47
+
During the prompts, provide values for:
48
+
* `aws_region` – AWS region (e.g. `us-east-1`)
49
+
* `prefix` – Unique prefix for all resource names
50
+
51
+
1. Note the outputs from the deployment. These contain the resource names and ARNs used for testing.
52
+
53
+
## How it works
54
+
55
+
1. EventBridge Scheduler fires on the configured schedule and invokes the orchestrator Lambda with a JSON payload containing `taskType`, `scheduleName`, and `scheduledTime`.
56
+
2. The orchestrator Lambda calls `bedrock-agent-runtime:InvokeAgent` with the payload, targeting the agent alias.
57
+
3. The Bedrock Agent parses the payload, generates an executive summary using the foundation model, and calls the `recordTaskExecution` action group.
58
+
4. The action group Lambda writes the execution record (task ID, type, scheduled time, summary, and recorded timestamp) to the DynamoDB table.
59
+
5. If the scheduler invocation fails after 3 retries, the event is sent to the SQS dead-letter queue.
60
+
61
+
## Testing
62
+
63
+
1. Replace `<prefix>` with the prefix chosen during deployment and invoke the orchestrator Lambda function manually:
0 commit comments