Skip to content

Releases: awslabs/swift-aws-lambda-runtime

2.4.0

21 Nov 20:19
2abe7eb

Choose a tag to compare

This release adds support for AWS Lambda tenant isolation mode.
https://aws.amazon.com/blogs/aws/streamlined-multi-tenant-application-development-with-tenant-isolation-mode-in-aws-lambda/

let runtime = LambdaRuntime {
    (event: APIGatewayRequest, context: LambdaContext) -> APIGatewayResponse in

    // Extract tenant ID from context
    guard let tenantID = context.tenantID else {
        return APIGatewayResponse(statusCode: .badRequest, body: "No Tenant ID provided")
    }

...

See Examples/MultiTenant for a full example.

What's Changed

SemVer Minor

Other Changes

Full Changelog: 2.3.1...2.4.0

2.3.1

22 Oct 11:13
b1553d2

Choose a tag to compare

This release is the first one in the repo new home (/awslabs).

It fixes two bugs in the LocalServer (the one started when you run your function locally during development or CI)

  • You can now invoke your streaming function multiple times without having to restart the server
  • You can now invoke the same test server in parallel. This is particularly useful for your CI

We also changed some of the legal docs (CONTRIBUTING, NOTICE, and the license headers) to match AWS's defaults.

As usual, continue to share your feedback and open issues. The full change log is below.

What's Changed

SemVer Patch

  • Allow multiple invocations of streaming Lambda functions with the local test server by @sebsto in #590
  • change references from /swift-server to /awslabs by @sebsto in #591
  • fix ci : check libFoundation on HelloWorld example by @sebsto in #593
  • [ci] Use APIGatewayV2 for link foundation check by @sebsto in #595
  • Replace standard documents and processes with AWS ones by @sebsto in #574
  • Accept multiple POST /invoke requests to allow parallel testing by @sebsto in #585

Full Changelog: 2.3.0...2.3.1

2.3.0

16 Oct 19:46
e3b74f3

Choose a tag to compare

You can now create a LambdaRuntime with a handler that accepts an event and a context, and returns Void.
This is useful for Lambda function that don't return a value, like the one that handle messages from an SQS queues.

import AWSLambdaEvents

struct MySQSHandler: LambdaHandler {
    func handle(_ event: SQSEvent, context: LambdaContext) async throws {
        // Process SQS messages
    }
}

let runtime = LambdaRuntime(lambdaHandler: MySQSHandler())

What's Changed

SemVer Minor

  • Add initializer with LambdaHandler directly with Decodable event and Void output by @natanrolnik in #589

Full Changelog: 2.2.0...2.3.0

2.2.0

14 Oct 22:32
9487a09

Choose a tag to compare

What's Changed

SemVer Minor

  • Lambda Handler errors now reports the root error in field errorType rather than "FunctionError" constant by @benrosen78 in #587

New Contributors

Full Changelog: 2.1.1...2.2.0

2.1.1

13 Oct 17:42
22f9f6d

Choose a tag to compare

What's Changed

SemVer Patch

  • Double time interval to allow test to succeed on slow machines by @sebsto in #583

Full Changelog: 2.1.0...2.1.1

2.1.0

09 Oct 17:22
461c18a

Choose a tag to compare

A new API to easily create a LambdaRuntime from a LambdaHandler when you choose to not use the closure syntax.

You can now write

let lambdaHandler = MyHandler()
let runtime = LambdaRuntime(lambdaHandler: lambdaHandler)

Thank you @natanrolnik for this contribution.

What's Changed

SemVer Minor

  • Add LambdaRuntime initializer with LambdaHandler directly with Codable support by @natanrolnik in #581

SemVer Patch

  • Remove links to runtime v1, add links to the doc on SPI by @sebsto in #576

Full Changelog: 2.0.0...2.1.0

2.0.0

29 Sep 08:43
8cfd36a

Choose a tag to compare

The AWS Lambda Runtime for Swift v2 is now officially available.

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
  • 200MB 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()

Changes between 2.0.0-beta.1 and 2.0.0

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
  • [fix] The library must compile when no traits are enabled by @sebsto in #563

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
  • add support for LOCAL_LAMBDA_PORT by @sebsto in #557
  • Bump Amazon RDS version 19 PG 17 by @sebsto in #561
  • Update toolchain and doc for 6.2 by @sebsto in #564
  • Apply recommendation for security and reliability by @sebsto in #573

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
  • refactor the Swift Settings in Package.swift by @sebsto in #558
  • Allow compiling on macOS by @fabianfett in #559
  • [Example] Use smaller containers in all examples by @sebsto in #571
  • [Example] Add APIGatewayV1 example by @everyplace in #569
  • Rename APIGateway example to APIGatewayV2 by @sebsto in #575

Other Changes

New Contributors

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

2.0.0-rc.1

23 Sep 19:20
a1ab8df

Choose a tag to compare

2.0.0-rc.1 Pre-release
Pre-release

Probably the last release before 2.0.0 GA

What's Changed

SemVer Major

  • [fix] The library must compile when no traits are enabled by @sebsto in #563

SemVer Minor

SemVer Patch

Full Changelog: 2.0.0-beta.3...2.0.0-rc.1

2.0.0-beta.3

03 Sep 16:32
d8ee71f

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

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