Releases: swift-server/swift-aws-lambda-runtime
2.0.0-beta.3
Here is v2.0.0 beta 3, with two set of changes
- The LocalServer that the library starts when you run your function locally for testing can now be configured with three environment variables
LOCAL_LAMBDA_HOST
(default to 127.0.0.1)
LOCAL_LAMBDA_PORT
(defaults to 7000)
LOCAL_LAMBDA_ENDPOINT
(defaults to/invoke
). This is renamed from LOCAL_LAMBDA_SERVER_ENDPOINT for consistency.
If you have testing scripts that use LOCAL_LAMBDA_SERVER_ENDPOINT
, you'll need to update them.
- We remove the
.platform[.macOS(v15)]
requirement fromPackage.swift
. The requirement is now enforced at code level (if you don't compile on macOS15, it will fail). This will simplify inclusions of the library in other packages that have a less strict.platform
constraint.
What's Changed
SemVer Minor
SemVer Patch
Full Changelog: 2.0.0-beta.2...2.0.0-beta.3
2.0.0-beta.2
Thank you for your feedback and comments on the first v2 beta. Here is beta 2, with a couple of API changes.
-
LambdaContext.ClientContext
is now astruct
(was aString?
). This is only used for client applications built with the AWS Mobile SDK (now deprecated in favor of AWS Amplify) -
LambdaContext
no more usesDispatchWallTime
to keep track of the execution timeout -
StreamingLambdaHandlerWithEvent
is now an example and not part of the runtime API. This struct introduced dependencies on Lambda Runtime Event, which we don't want in the runtime.
Other minor changes have been introduced: a new Hummingbird Lambda example, fixes in doc, better error reporting when the Lambda data plane closes the connection, fix the performance test scripts, and more. The full list is below.
We target to publish v2 by end of September or first week of October. Please let us know your feedback as soon as you can.
What's Changed
SemVer Major
- Use a struct for ClientContext (fix #169) by @sebsto in #539
- Remove dependency on DispatchWallTime (fix #384) by @sebsto in #540
- Revert streaming codable handler and provide it as an example, not an API by @sebsto in #549
SemVer Minor
- Performance Test the invocation loop (fix #377) by @sebsto in #542
- Add hummingbird Lambda example by @sebsto in #544
- Propagate Connection Closed Information up to top-level (fix #465) by @sebsto in #545
SemVer Patch
- fix: Fix deadline header with correct instant value (#551) by @sebsto in #552
- Split LambdaRuntimeClient in two files for easier reading by @sebsto in #554
- Rename Tests'
timeout()
function by @sebsto in #555
Other Changes
- Fix link (Response Streaming) in readme.md by @natanrolnik in #543
- [doc] Updated streaming response limit to 200 MB by @dsplatonov in #548
New Contributors
- @natanrolnik made their first contribution in #543
- @dsplatonov made their first contribution in #548
Full Changelog: 2.0.0-beta.1...2.0.0-beta.2
2.0.0-beta.1
Swift AWS Lambda Runtime v2 Release Notes
Beta Release History
- v2.0.0-beta.1: initial v2 beta. Please provide feedback about bugs, general usability, documentation, or example code. In case of a problem, please share a pull request, or open an issue.
Overview
Swift AWS Lambda Runtime v2 introduces a complete redesign of the API with async/await-first architecture, response streaming support, background task execution, and seamless integration with Swift Service Lifecycle. This release prioritizes developer experience, and structured concurrency.
🚀 v2 - Major New Features
Complete Swift 6 Concurrency Integration
- Full async/await support throughout the entire API surface
- Structured concurrency with proper task management and cancellation
- Swift 6 compatibility with complete concurrency checking
- Non-blocking I/O foundation built on SwiftNIO for optimal performance
- Own the main() function for complete control over initialization
// Clean async/await API
let runtime = LambdaRuntime { (event: Input, context: LambdaContext) async throws -> Output in
let result = try await someAsyncOperation()
return Output(data: result)
}
try await runtime.run()
Response Streaming Support
- Stream large responses incrementally to improve time-to-first-byte (TTFB) performance
- 20MB soft limit for streamed responses vs 6MB for buffered responses
- Reduced memory usage for large responses
- Support for custom HTTP status codes and headers in the streamed response
let runtime = LambdaRuntime { (event: StreamingRequest, responseWriter, context: LambdaContext) in
for i in 1...10 {
try await responseWriter.write(ByteBuffer(string: "Message \(i)\n"))
try await Task.sleep(for: .milliseconds(500))
}
try await responseWriter.finish()
}
Background Task Execution
- Execute code after returning response without affecting response latency
- Structured concurrency approach following Swift best practices
let runtime = LambdaRuntime { (event: Input, outputWriter: some LambdaResponseWriter<Output>, context: LambdaContext) in
// Return response immediately
try await output.write(Greeting(message: event.message))
// Execute background work
try await performAnalytics(event)
try await updateCache()
}
Swift Service Lifecycle Integration
- Structured dependency with ServiceGroup
- Graceful shutdown handling with proper resource cleanup
- Eliminate LambdaTerminator complexity
let postgresClient = PostgresClient()
let runtime = LambdaRuntime { (event: Input, context: LambdaContext) in
try await postgresClient.query("SELECT * FROM users")
}
let serviceGroup = ServiceGroup(
services: [postgresClient, runtime],
configuration: .init(gracefulShutdownSignals: [.sigterm])
)
try await serviceGroup.run()
🔄 API Changes
- Only supports Swift 6.0 or more recent
New Handler Protocols
StreamingLambdaHandler (Base Protocol)
- Handles raw
ByteBuffer
input/output - Full control over response streaming
- Support for background task execution
LambdaHandler (Simplified)
- Generic
Event
andOutput
types - Automatic JSON encoding/decoding
- Clean
handle(event, context) -> Output
signature
LambdaWithBackgroundProcessingHandler
- Combines type safety with background task support
- Uses
LambdaResponseWriter
for structured response handling
Closure-Based API
// Simple JSON in/out
let runtime = LambdaRuntime { (event: HelloRequest, context: LambdaContext) in
HelloResponse(greetings: "Hello \(event.name)")
}
// Streaming with JSON input
let runtime = LambdaRuntime { (event: StreamingRequest, responseWriter, context: LambdaContext) in
// Stream response while maintaining type safety
}
Simplified Local Testing
- Automatic local server when
AWS_LAMBDA_RUNTIME_API
is not set - No environment variables required for local development
- Port 7000 for local invocations on
/invoke
(configurable viaLOCAL_LAMBDA_SERVER_INVOCATION_ENDPOINT
)
🛠 Breaking Changes
Removed APIs
LambdaTerminator
(replaced by ServiceLifecycle)EventLoop
interfaces (replaced by async/await)ByteBufferAllocator
fromLambdaContext
- Protocol-based
@main
implementations
Migration Path
- Replace protocol conformance with closure-based handlers or create your own handler function.
- Update to async/await throughout your codebase
- Use ServiceGroup for dependency management, if needed
- Use Swift 6.x
📦 Enhanced Codable Support
Generic Adapters
- LambdaCodableAdapter: Wraps any handler with encoding/decoding
- LambdaHandlerAdapter: Adapts simple handlers for background processing
- Custom encoders/decoders: Support for any format beyond JSON
Protocol-Based Encoding
public protocol LambdaEventDecoder {
func decode<Event: Decodable>(_ type: Event.Type, from buffer: ByteBuffer) throws -> Event
}
public protocol LambdaOutputEncoder {
func encode<Output: Encodable>(_ value: Output, into buffer: inout ByteBuffer) throws
}
🧪 Examples and Documentation
New Examples
- ServiceLifecycle + PostgreSQL: Complete database integration example, with Swift Service Lifecycle
- Streaming responses: Multiple streaming patterns
- Background tasks: Post-response processing examples
- API Gateway integration: HTTP API with Lambda
- Security best practices implementations
- and more...
Comprehensive Documentation
- A quick start guide.
- A deployment guide covering deployment with the AWS Console, the AWS Command Line Interface (CLI), the Simple Application Model (SAM) and the Cloud Development Kit (CDK).
- A tutorial with step by step instructions
📋 Requirements
- Swift 6.x toolchain
- macOS 15 (Sequoia) or later for development on macOS.
- Docker for building Lambda functions
- AWS CLI configured with appropriate permissions
🚧 Beta Limitations
- API may change based on community feedback
- Documentation in progress for advanced use cases
🔄 Migration Guide
From v1 to v2
- Update Package.swift to use v2.0.0-beta.1 version
- Replace handler protocols with closure-based approach
- Integrate ServiceLifecycle for dependency management, if needed
- Test thoroughly with new local server
Compatibility
- v1 and v2 can coexist in different projects
- No automatic migration - manual code changes required
🤝 Community Feedback
This beta release incorporates extensive community feedback from the Swift forums discussion. We encourage continued feedback on:
- API ergonomics and developer experience
- Performance characteristics
- Integration patterns with other Swift libraries
- Documentation clarity and completeness
📚 Resources
- Tutorial: Swift AWS Lambda Runtime Tutorial
- Deployment Guide: Comprehensive Deployment Documentation
- Examples: Complete working examples in the
Examples/
directory - API Documentation: Full API reference with code samples
New Contributors
- @aryan-25 made their first contribution in #341
- @FranzBusch made their first contribution in #340
- @jrosen081 made their first contribution in #386
- @t089 made their first contribution in #433
- @ptoffy made their first contribution in #477
- @mattcorey made their first contribution in #484
Full Changelog: 1.0.0-alpha.3...2.0.0-beta.1
Note: This is a beta release intended for testing and feedback. Production use should carefully evaluate stability and performance characteristics.
1.0.0-alpha.3
TL;DR
This is the last 1.0.0-alpha.x release. We started to work on a v2 that will embrace Swift6, structured concurrency, service lifecycles amongst other changes. You can read more about the proposed changes in this PR.
Thank you to all contributors.
Some notable changes
-
You can now use an environment variable to specify the local lambda invocation endpoint (by @jsonfry in #321)
-
You can now package project's resources in the generated ZIP file (by @camdenfullmer in #333)
-
You can now have tasks that will run after a response is returned, but before the runtime fetches the next event (aka detached tasks) (by @Buratti in #334) - This API will change for v2
Detailed list of changes
- fixed typo in readme by @MarwaneKoutar in #319
- Add tracing of request events + mention LOG_LEVEL in README by @sebsto in #315
- Local lambda invocation endpoint env var by @jsonfry in #321
- [plugin] Use LAMBDA_USE_LOCAL_DEPS env var in local builds with docker by @sebsto in #325
- add LOCAL_LAMBDA_SERVER_INVOCATION_ENDPOINT to the readme by @sebsto in #326
- Fix compile error on Windows by @finestructure in #328
- Allow to compile with the Linux Static SDK (aka musl) by @sebsto in #331
- Add support for resources when packaging using the SwiftPM plugin by @camdenfullmer in #333
- Update soundness.sh to support 2024 and 2025 by @sebsto in #335
- Examples list documents by @fitomad in #336
- Add Vapor's Penny by @0xTim in #338
- Update projects.md by @finestructure in #337
- [Draft] Detached tasks by @Buratti in #334
- apply swiftformat by @sebsto in #342
- Add Breeze to projects.md by @Andrea-Scuderi in #343
New Contributors
- @MarwaneKoutar made their first contribution in #319
- @jsonfry made their first contribution in #321
- @finestructure made their first contribution in #328
- @0xTim made their first contribution in #338
- @Buratti made their first contribution in #334
Full Changelog: 1.0.0-alpha.2...1.0.0-alpha.3
1.0.0-alpha.2
What's Changed
- Add note about naming the file main.swift to README by @camdenfullmer in #283
- README.MD SimpleLambdaHandler example with events. by @fitomad in #286
- Archive plugin documentation by @fitomad in #287
- Issue template v2 by @fitomad in #290
- improve examples by @tomerd in #292
- Fix a dead tutorial link by @Joannis in #301
- remove swift-backtrace in swift >= 5.9 by @tomerd in #305
- [doc] Getting Started documentation and tutorial by @sebsto in #300
- Add
--disable-docker-image-update
plugin flag by @florentmorin in #311 - Don't log work fetching failure at error. by @tachyonics in #313
- remove redundant pre-concurrency flag by @tomerd in #314
- Include the docc tutorial into 1.0.0 by @sebsto in #316
- allow custom initialization of the HandlerType of the LambdaRuntime by @tomerd in #310
New Contributors
- @camdenfullmer made their first contribution in #283
- @fitomad made their first contribution in #286
- @Joannis made their first contribution in #301
- @sebsto made their first contribution in #307
- @florentmorin made their first contribution in #311
- @tachyonics made their first contribution in #313
Full Changelog: 1.0.0-alpha.1...1.0.0-alpha.2
1.0.0-alpha.1
First alpha for 1.0 release
What's Changed
- Change Lambda.Context from class to struct by @jareyesda in #217
- Clean up dependency graph and imports by @Lukasa in #218
- Renamed completeWithAsync to completeWithTask by @saltzmanjoelh in #221
- split events into spearate package by @tomerd in #216
- Use explicit NIO imports by @fabianfett in #220
- InitializationContext should be a value not reference type by @fabianfett in #219
- Update examples for Swift 5.5 by @fabianfett in #223
- Drop sync and closure APIs by @fabianfett in #222
- Reorder Event and Context. by @fabianfett in #224
- [RFC] Drop event label from handle methods in LambdaHandlers by @fabianfett in #225
- Remove dependency on _NIOConcurrency by @fabianfett in #229
- update and add examples to new APIs by @tomerd in #228
- Rename
Lambda.Lifecycle
toLambdaRuntime
by @fabianfett in #232 - Rename Lambda.Context to LambdaContext by @fabianfett in #233
- Modernize app example by @stevapple in #231
- Adopt concurrency adoption guidelines by @stevapple in #230
- Add ControlPlaneRequest, ControlPlaneResponse by @fabianfett in #238
- Add LambdaRequestID by @fabianfett in #243
- Add ControlPlaneRequestEncoder by @fabianfett in #239
- Lambda factory as a protocol requirement. by @fabianfett in #244
- Add default value for traceID header by @StefanNienhuis in #246
- terminator handler by @tomerd in #251
- adoption of sendable by @tomerd in #252
- remove extension for JSONEncoder and JSONDecoder by @tomerd in #257
- prefix data structures with Lambda instead of namespacing them by @tomerd in #256
- Add script to check for API breaks by @fabianfett in #258
- Some documentation fixes by @fabianfett in #260
- Add special Deployment instructions for the Mac M1 by @gestrich in #263
- packaging plugin by @tomerd in #254
- Fix performance test script by @stevapple in #264
- DocC setup by @yim-lee in #270
- API Refactoring by @tomerd in #273
- fix concurrency api usage by @tomerd in #282
New Contributors
- @jareyesda made their first contribution in #217
- @Lukasa made their first contribution in #218
- @saltzmanjoelh made their first contribution in #221
- @stevapple made their first contribution in #231
- @StefanNienhuis made their first contribution in #246
- @gestrich made their first contribution in #263
- @sja26 made their first contribution in #269
- @yim-lee made their first contribution in #270
Full Changelog: 0.5.0...1.0.0-alpha.1
0.5.2
0.5.1
- Clean up dependency graph and imports (#218)
- Renamed completeWithAsync to completeWithTask (#221) - Thanks @saltzmanjoelh
0.5.0
- Fixes platform requirements (#214)
- SNS MessageAttributes are optional (#208) - Thanks @DwayneCoussement
- Inline and specialize LambdaHandlers (#201)
- Small Performance Improvements (#199)
- Updated S3.Event (#195) - Thanks @mufumade
- Async/await support (#186)
- Multiple updates to CI setup, code formatting, etc (#189, #190, #191, #196, #197, #198, #202, #207, #211)
- Adopt SSWG security guidelines (#209)
0.4.0
- Fixed typo in LambdaRunner.swift documentation (#171) - Thanks @filletofish
- Removed symbolicate-linux-fatal from Docker (#173)
- Properties of HTTPResponses are now
var
inAPIGateway.Response
,APIGateway.V2.Response
,ALB.TargetGroupResponse
(#176) - Fixed the visibility of the JWT in
APIGateway.V2.Request
(#178) - Thanks @JBosecker - Fixed typo in SQS example (#181) - Thanks @mattmassicotte
- Fixed the queryStringParameters variable for
ALB.TargetGroupResponse
(#182) - Thanks @proggeramlug - Fixed typo in README.md (#183) - Thanks @mr-j-tree
- Use welcoming language everywhere (#184)
- Added support for AppSync events (#187) - Thanks @DwayneCoussement
- Added CI support for Swift 5.4 (#189)