Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: swift-server/swift-aws-lambda-runtime

2.0.0-beta.3

03 Sep 16:32
d8ee71f
Compare
Choose a tag to compare
2.0.0-beta.3 Pre-release
Pre-release

Here is v2.0.0 beta 3, with two set of changes

  1. 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.

  1. We remove the .platform[.macOS(v15)] requirement from Package.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

  • refactor the Swift Settings in Package.swift by @sebsto in #558

Full Changelog: 2.0.0-beta.2...2.0.0-beta.3

2.0.0-beta.2

01 Sep 11:38
ec28c96
Compare
Choose a tag to compare
2.0.0-beta.2 Pre-release
Pre-release

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 a struct (was a String?). This is only used for client applications built with the AWS Mobile SDK (now deprecated in favor of AWS Amplify)

  • LambdaContext no more uses DispatchWallTime 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

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

New Contributors

Full Changelog: 2.0.0-beta.1...2.0.0-beta.2

2.0.0-beta.1

30 Jul 15:12
0a6af5b
Compare
Choose a tag to compare
2.0.0-beta.1 Pre-release
Pre-release

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 and Output 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 via LOCAL_LAMBDA_SERVER_INVOCATION_ENDPOINT)

🛠 Breaking Changes

Removed APIs

  • LambdaTerminator (replaced by ServiceLifecycle)
  • EventLoop interfaces (replaced by async/await)
  • ByteBufferAllocator from LambdaContext
  • Protocol-based @main implementations

Migration Path

  1. Replace protocol conformance with closure-based handlers or create your own handler function.
  2. Update to async/await throughout your codebase
  3. Use ServiceGroup for dependency management, if needed
  4. 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

  1. Update Package.swift to use v2.0.0-beta.1 version
  2. Replace handler protocols with closure-based approach
  3. Integrate ServiceLifecycle for dependency management, if needed
  4. 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

New Contributors

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

26 Aug 11:09
5ecc24f
Compare
Choose a tag to compare
1.0.0-alpha.3 Pre-release
Pre-release

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

New Contributors

Full Changelog: 1.0.0-alpha.2...1.0.0-alpha.3

1.0.0-alpha.2

19 Jan 17:15
8d9f44b
Compare
Choose a tag to compare
1.0.0-alpha.2 Pre-release
Pre-release

What's Changed

New Contributors

Full Changelog: 1.0.0-alpha.1...1.0.0-alpha.2

1.0.0-alpha.1

12 Jan 17:55
de730b2
Compare
Choose a tag to compare
1.0.0-alpha.1 Pre-release
Pre-release

First alpha for 1.0 release

What's Changed

New Contributors

Full Changelog: 0.5.0...1.0.0-alpha.1

0.5.2

05 Oct 00:23
699ada1
Compare
Choose a tag to compare
0.5.2 Pre-release
Pre-release
  • Add guards for code that relies on _Concurrency to allow compilation with Xcode 13 (#237) - Thanks @programmarchy

0.5.1

24 Aug 16:39
Compare
Choose a tag to compare
0.5.1 Pre-release
Pre-release
  • Clean up dependency graph and imports (#218)
  • Renamed completeWithAsync to completeWithTask (#221) - Thanks @saltzmanjoelh

0.5.0

22 Jul 21:41
a9e15b1
Compare
Choose a tag to compare
0.5.0 Pre-release
Pre-release

0.4.0

03 Mar 22:12
e33e4af
Compare
Choose a tag to compare
0.4.0 Pre-release
Pre-release
  • Fixed typo in LambdaRunner.swift documentation (#171) - Thanks @filletofish
  • Removed symbolicate-linux-fatal from Docker (#173)
  • Properties of HTTPResponses are now var in APIGateway.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)