New serverless pattern - agentcore-gateway-eventbridge-cdk - #3309
Open
antoinebgit wants to merge 1 commit into
Open
antoinebgit wants to merge 1 commit into
antoinebgit wants to merge 1 commit into
Conversation
…ore Gateway pattern
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the
agentcore-gateway-eventbridge-cdkpattern: 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.This pattern was originally filed alongside
eventbridge-apidestination-agentcore-cdkin #3282. Split into its own PR as requested by @marcojahn. #3282 now contains only theeventbridge-apidestination-agentcore-cdkpattern.How it works
AWS_IAM, so every request must carry a valid SigV4 signature for thebedrock-agentcoreservice. The Runtime execution role is grantedbedrock-agentcore:InvokeGatewayscoped to the Gateway ARN.agent-code/sigv4.pywrapsbotocore.auth.SigV4Authas anhttpx.Authimplementation and passes it tostreamablehttp_client(url, auth=sigv4_auth).emit_eventtool backed by a Lambda function. The Lambda validates the source prefix (onlyagent.*is allowed) and callsevents:PutEventson a custom bus.PutEventsto 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 OKfrom the Gateway MCP endpoint, theemit_eventtool invokes successfully, and EventBridge returns an event ID withFailed Count: 0. The README documents the two most common failure modes (403 Forbiddenfrom a missingInvokeGatewaypermission or malformed signature, and a tool-listingAttributeErrorfrom incompatiblestrands-agents/mcpversions).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
README.md,example-pattern.json, andarchitecture.pngmaincdk destroytested and removes all resources