-
Notifications
You must be signed in to change notification settings - Fork 118
Add Multi-Source API Example #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new MultiSourceAPI example that demonstrates a Lambda function capable of handling requests from both Application Load Balancer (ALB) and API Gateway V2. The handler receives raw ByteBuffer events and uses pattern matching with type-safe decoding to determine the event source and return the appropriate response.
Key changes:
- Implements a
StreamingLambdaHandlerthat decodes incoming events as eitherALBTargetGroupRequestorAPIGatewayV2Request - Includes complete AWS infrastructure setup with VPC, subnets, ALB, and API Gateway V2
- Adds the new example to the CI workflow
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Examples/MultiSourceAPI/Sources/main.swift | Core Lambda handler implementing multi-source event processing logic |
| Examples/MultiSourceAPI/Package.swift | Swift package manifest defining dependencies and build configuration |
| Examples/MultiSourceAPI/template.yaml | SAM template defining AWS infrastructure including ALB and API Gateway |
| Examples/MultiSourceAPI/samconfig.toml | SAM CLI configuration for deployment |
| Examples/MultiSourceAPI/README.md | Documentation explaining usage and deployment |
| Examples/MultiSourceAPI/.gitignore | Standard Swift project ignore patterns |
| Examples/MultiSourceAPI/.aws-sam/build/template.yaml | Generated SAM build artifact |
| Examples/MultiSourceAPI/.aws-sam/build.toml | Generated SAM build metadata |
| .github/workflows/pull_request.yml | Updated CI workflow to include new example |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Josh Elkins <[email protected]>
This PR adds a new example demonstrating how to build a Lambda function that handles requests from multiple sources (Application Load Balancer and API Gateway V2) using a single handler.
What's New
New Example:
Examples/MultiSourceAPIA Lambda function that:
StreamingLambdaHandlerto accept rawByteBuffereventsALBTargetGroupRequestorAPIGatewayV2RequestKey Features
Decodableto identify the event source at runtimeStreamingLambdaHandlerfor efficient response handlingFiles Added
Examples/MultiSourceAPI/Sources/main.swift- Lambda handler implementationExamples/MultiSourceAPI/Package.swift- Swift package configurationExamples/MultiSourceAPI/template.yaml- SAM deployment template with ALB and API Gateway V2Examples/MultiSourceAPI/README.md- Documentation with build, deploy, and test instructionsUse Case
This pattern is useful when you want to: