Skip to content

New serverless pattern - agentcore-gateway-eventbridge-cdk - #3309

Open
antoinebgit wants to merge 1 commit into
aws-samples:mainfrom
antoinebgit:agentcore-gateway-eventbridge-cdk
Open

antoinebgit wants to merge 1 commit into
aws-samples:mainfrom
antoinebgit:agentcore-gateway-eventbridge-cdk

Conversation

@antoinebgit

Copy link
Copy Markdown

Description

Adds the agentcore-gateway-eventbridge-cdk pattern: an AI agent on Amazon Bedrock AgentCore Runtime emits structured business events to Amazon EventBridge through a governed AgentCore Gateway MCP tool, authenticated with IAM SigV4.

  • Level: 300
  • Framework: CDK (TypeScript)
  • Services: Bedrock AgentCore Runtime, Bedrock AgentCore Gateway, Amazon Bedrock, Lambda, EventBridge

This pattern was originally filed alongside eventbridge-apidestination-agentcore-cdk in #3282. Split into its own PR as requested by @marcojahn. #3282 now contains only the eventbridge-apidestination-agentcore-cdk pattern.

How it works

  • The agent (Strands, Claude Haiku 4.5) connects to the AgentCore Gateway over the MCP Streamable HTTP transport (2025-03-26 spec).
  • The Gateway's inbound authorization is AWS_IAM, so every request must carry a valid SigV4 signature for the bedrock-agentcore service. The Runtime execution role is granted bedrock-agentcore:InvokeGateway scoped to the Gateway ARN.
  • No MCP client SDK signs streamable-HTTP requests with SigV4 natively, so this pattern signs them explicitly: agent-code/sigv4.py wraps botocore.auth.SigV4Auth as an httpx.Auth implementation and passes it to streamablehttp_client(url, auth=sigv4_auth).
  • The Gateway exposes an emit_event tool backed by a Lambda function. The Lambda validates the source prefix (only agent.* is allowed) and calls events:PutEvents on a custom bus.
  • IAM follows least privilege throughout: the Runtime role can only invoke the specific Gateway, the Gateway role can only invoke the specific Lambda, and the Lambda can only PutEvents to the specific bus.

The README also explains why routing through Gateway is preferable to giving the agent direct EventBridge SDK access: single point of schema enforcement, fleet-wide rate limiting, blast radius containment, credential isolation, MCP tool discovery, centralized observability, and policy evolution without redeploying agents.

Testing

Deployed and tested end-to-end in a live account. Verified the SigV4-signed request returns 200 OK from the Gateway MCP endpoint, the emit_event tool invokes successfully, and EventBridge returns an event ID with Failed Count: 0. The README documents the two most common failure modes (403 Forbidden from a missing InvokeGateway permission or malformed signature, and a tool-listing AttributeError from incompatible strands-agents/mcp versions).

The CDK stack is fully self-contained: it builds and deploys the agent container, the Gateway with its Lambda tool backend, and the EventBridge custom bus.

Checklist

  • Pattern folder contains README.md, example-pattern.json, and architecture.png
  • Branch is based on the latest main
  • cdk destroy tested and removes all resources
  • No account IDs, IP addresses, or credentials committed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants