Commit Graph
361 Commits
Author SHA1 Message Date
Sébastien Stormacq 11bea7b2ee Performance Test the invocation loop (fix #377) (#542)
re-implement MAX_INVOCATIONS and fix shell script 
Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/377

### Motivation:

In v1, there was a script measuring the performance of the invocation
loop.
Re-instate this script to allow users and developers to measure the
performance impact of their changes.

### Modifications:

I re-implemented MAX_INVOCATIONS, to avoid the client looping against
the Mock Server. But this time, MAX_INVOCATIONS is handled on the
server, not on the client.

I slightly modified the script to work with v2 and the new MockServer.

### Result:

The script works.

This PR has a dependency on
https://github.com/swift-server/swift-aws-lambda-runtime/issues/465
2025-08-05 08:39:20 +02:00
Sébastien StormacqandKonrad `ktoso` Malawski bae9f27ccb Use a struct for ClientContext (fix #169) (#539)
Do not use a String for Lambdacontext.ClientContext, use a struct instead.
Fix for https://github.com/swift-server/swift-aws-lambda-runtime/issues/169

Note: this PR introduces an API change that will break function using
`LambdaContext`, we should integrate this change during the beta
otherwise it will require a major version bump.

### Motivation:

Let the compiler detect type errors for us

### Modifications:

- Create a struct for ClientContext and it's embedded ClientApplication
- add three unit test to validate the struct 

### Result:

No more String?

---------

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2025-08-04 08:24:46 +02:00
Natan Rolnik 76c3a441de Fix link (Response Streaming) in readme.md (#543)
When reading about the V2 changes , I noticed that the link for Response
Streaming in the AWS docs was leading to a 404.

A trailing `]` character was the reason - this PR fixes it.
2025-08-03 12:30:17 +00:00
Sébastien Stormacq 0a6af5b4e1 prepare 2.0.0-beta.1 (#538)
Change dependencies in `Examples/*` and documentation to `from:
"2.0.0-beta.1"`
2.0.0-beta.1
2025-07-30 19:08:39 +04:00
Sébastien Stormacq e6ba07fd06 [example] Add example for Swift Service Lifecycle (#522)
Now that task cancellation works, re publishing this PR with a new
example for Swift Service Lifecycle
2025-07-30 06:40:55 +04:00
Sébastien Stormacq 36dadf9c26 [doc] fix header level warnings from CI soundness/doc scripts (#537)
```
note: The majority of content should be under level-3 headers under the "Overview" section
  --> Deployment.md:22:1-22:17
20 |   * [Third-party tools](#third-party-tools)
21 |
22 + ## Prerequisites
   | ╰─suggestion: Change the title to "Overview"
23 |
24 | 1. Your AWS Account

```

and many others.

Action: I lowered all titles one level down.
2025-07-25 20:13:07 +04:00
Sébastien Stormacq 9287d56e60 [core] Implement Lambda streaming with custom HTTP headers (#521)
Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/520
2025-07-24 15:03:29 +04:00
Sébastien StormacqandTim Condon 412a345bdd [core] Add user-facing API for Streaming Lambda functions that receive JSON events (#532)
Add user-facing API for Streaming Lambda functions that receives JSON
events

### Motivation:

Streaming Lambda functions developed by developers had no choice but to
implement a handler that receives incoming data as a `ByteBuffer`. While
this is useful for low-level development, I assume most developers will
want to receive a JSON event to trigger their streaming Lambda function.

Going efficiently from a `ByteBuffer` to a Swift struct requires some
code implemented in the `JSON+ByteBuffer.swift` file of the librray. We
propose to further help developers by providing them with a new
`handler()` function that directly receives their `Decodable` type.

### Modifications:

This PR adds a public facing API (+ unit test + updated README) allowing
developers to write a handler method accepting any `Decodable` struct as
input.

```swift
import AWSLambdaRuntime
import NIOCore

// Define your input event structure
struct StreamingRequest: Decodable {
    let count: Int
    let message: String
    let delayMs: Int?
}

// Use the new streaming handler with JSON decoding
let runtime = LambdaRuntime { (event: StreamingRequest, responseWriter, context: LambdaContext) in
    context.logger.info("Received request to send \(event.count) messages")
    
    // Stream the messages
    for i in 1...event.count {
        let response = "Message \(i)/\(event.count): \(event.message)\n"
        try await responseWriter.write(ByteBuffer(string: response))
        
        // Optional delay between messages
        if let delay = event.delayMs, delay > 0 {
            try await Task.sleep(for: .milliseconds(delay))
        }
    }
    
    // Finish the stream
    try await responseWriter.finish()
    
    // Optional: Execute background work after response is sent
    context.logger.info("Background work: processing completed")
}

try await runtime.run()
```

This interface provides:
- **Type-safe JSON input**: Automatic decoding of JSON events into Swift
structs
- **Streaming responses**: Full control over when and how to stream data
back to clients
- **Background work support**: Ability to execute code after the
response stream is finished
- **Familiar API**: Uses the same closure-based pattern as regular
Lambda handlers

Because streaming Lambda functions can be invoked either directly
through the API or through Lambda Function URL, this PR adds the
decoding logic to support both types, shielding developers from working
with Function URL requests and base64 encoding.

We understand these choice will have an impact on the raw performance
for event handling. Those advanced users that want to get the maximum
might use the existing `handler(_ event: ByteBuffer, writer:
LambaStreamingWriter)` function to implement their own custom decoding
logic.

This PR provides a balance between ease of use for 80% of the users vs
ultimate performance, without closing the door for the 20% who need it.

### Result:

Lambda function developers can now use arbitrary `Decodable` Swift
struct or Lambda events to trigger their streaming functions. 🎉

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2025-07-23 19:03:25 +04:00
Sébastien Stormacq f1514b13d1 [core] Add support for streaming function to the local server (#531)
The local server used for testing functions locally (`swift run`) now
support streaming lambda functions

Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/528
2025-07-23 10:08:14 +04:00
Sébastien StormacqandCopilot cb85fdd782 fix [core] trace level shows the first kb of the payload before being decoded (#534)
Add a log statement in the Lambda loop, before calling the user's
handler to show the raw payload before any attempt to decode it.

This was available in Runtime v1 and is now ported to v2.
This fixes
https://github.com/swift-server/swift-aws-lambda-runtime/issues/404

### Motivation:

This is useful when handling custom event and there is a Decoding error.
It allows to see the exact payload received by the handler before any
attempt to decode it.

### Modifications:

Add a log.trace statement with metatadata. Metadata are computed only
when the log level is trace or below.

### Result:

```
2025-07-21T08:58:33+0200 trace LambdaRuntime : Event's first bytes={"name": "me", "age": 50} aws-request-id=769127502334125 [AWSLambdaRuntime] sending invocation event to lambda handler
```

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-22 07:31:00 +02:00
Sébastien Stormacq db7e7897eb [test] Add a test for cancellable (#529)
- Add a test on `LambdaRuntime` for cancellable.
- Move the service life cycle test to its own file
2025-07-21 15:15:55 +02:00
Sébastien Stormacq e786f2f620 fix: [core] Hard code version number in user agent string (#98) (#533)
Add a hard coded version number to the user agent string, for an
eventual identification by the Lambda service

### Motivation:

It's [an
issue](https://github.com/swift-server/swift-aws-lambda-runtime/issues/108)
that was open more than 5 years ago and was never addressed. At the
time, the consensus was to pickup a version number for the Package.swift
file and the maintainer at the time decided to wait for Swift to
implement this.
Five years later, and several major version of Swift later, this is
still not available. I decided to move on and implement a less optimal
solution. This can be replaced in the future if package version ever
becomes part of Package.swift.

### Modifications:

Add a version enum to isolate the versioning in one place. I decided to
keep it simple and not over engineering it with major, minor, patch and
pre-release. At the time, it's a simple string. This is all what we need
for usage in the user agent string.

### Result:

User agent now identifies as `Swift-Lambda/2,0` instead of
`Swift-Lambda/unknown`
2025-07-21 15:15:02 +02:00
Sébastien Stormacq aa21cb2daa Update dependencies in CDK example (#535)
ran `npm update` to update `package-lock` file

### Motivation:

Should fix a dependabot security alert 

https://github.com/swift-server/swift-aws-lambda-runtime/security/dependabot/7

### Modifications:

just updated `Package-lock.json` file
2025-07-21 09:23:57 +02:00
Sébastien Stormacq dede067fa1 [tests] minor changes, mostly syntaxic (#530)
tiny syntax changes in the test suite
2025-07-12 11:30:04 +02:00
Sébastien Stormacq 4a7d95e4a3 fix: remove unused code in v2 (#427) 2025-07-04 16:41:07 +02:00
344d30b401 [core] Only one LambdaRuntime.run() can be called at a time (fix #507) (#508)
This is a proposal to fix issue #507 

**changes**
- `LambdaRuntime.init()` uses a `Mutex<Bool>` to make sure only one
instance is created
- `LambdaRuntime.init()` can now throw an error in case an instance
already exists (I did not use `fatalError()` to make it easier to test)
- All `convenience init()` methods catch possible errors instead of
re-throwing it to a void breaking the user-facing API
- Renamed existing `LambdaRuntimeError` to `LambdaRuntimeClientError`
- Introduced a new type `LambdaRuntimeError` to represent the double
initialization error

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Adam Fowler <adamfowler71@gmail.com>
2025-07-04 13:55:58 +00:00
Sébastien Stormacq bf2385ae08 Plugin v2 proposal (#448)
A proposal for a new set of SwiftPM plugins to facilitate the
scaffolding, build, archive, and deployment of Lambda functions.

This is a call for comments to finalize the design before starting an
actual implementation
2025-07-02 14:20:37 +02:00
Sébastien Stormacq de38324789 [core] Give user the possibility to pass their logger to the lambda runtime (#523)
Allow user to give their logger to the LambdaRuntime.

### Motivation:

Overloaded versions of `LambdaRuntime.init` don't allow to pass a logger

### Modifications:

Add a `logger` parameter to overloaded versions of `LambdaRuntime.init`

### Result:

It is now possible to write 

```
        let runtime = LambdaRuntime(logger: Logger(label: "MyLogger"), body: handler)
```
2025-07-01 20:44:59 +02:00
Adam Fowler b2811a5e1a Add support for local server graceful shutdown (#519)
- Add ServiceLifecycle version of `LambdaRuntime.run` that wraps
internal `_run` call in `cancelOnGracefulShutdown`
- Add cancellation handlers for shutting down existing connections in
Local lambda
- Added test for lambda graceful shutdown

### Motivation:

Ensure local lambda supports graceful shutdown
2025-06-29 09:05:15 +02:00
Adam Fowler b3fbee6b58 Add SendableMetatype conformance (#518)
Add SendableMetatype conformance to StreamingLambdaHandler

### Motivation:

Swift 6.2 introduced new protocol SendableMetatype for Types that are
Sendable

### Modifications:

Added `_Lambda_SendableMetatype` typealias for SendableMetatype in Swift
6.2

and 

```swift
public protocol StreamingLambdaHandler: _Lambda_SendableMetatype {
```

### Result:

No more compile warnings
2025-06-28 19:09:51 +02:00
Sébastien Stormacq a616996722 [test] add a unit test for the LambdaHTTPServer Pool (#500) 2025-06-28 14:11:28 +02:00
Sébastien StormacqandCopilot 935ea0fe91 Remove dependency on XCTest (#516)
Remove dependency on XCTest

### Motivation:

As 6.1 does not include XCTest anymore, finish the migration to Swift
testing

### Modifications:

Replace XCTest by Swift Testing in two files

### Result:

`swift test` works on 6.1.2

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-28 13:09:44 +02:00
dependabot[bot]andSébastien Stormacq 41c5edaf04 Bump aws-cdk-lib from 2.183.0 to 2.189.1 in /Examples/CDK/infra (#514)
Bumps
[aws-cdk-lib](https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib)
from 2.183.0 to 2.189.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/aws/aws-cdk/releases">aws-cdk-lib's
releases</a>.</em></p>
<blockquote>
<h2>v2.189.1</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>core:</strong> implicit Aspect applications do not override
custom Aspect applications (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34132">#34132</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/b7f4bc7aee1d99b70e4d9d3cedea53e910ee37ef">b7f4bc7</a>)</li>
</ul>
<hr />
<h2>Alpha modules (2.189.1-alpha.0)</h2>
<h2>v2.189.0</h2>
<h3>Features</h3>
<ul>
<li><strong>apigatewayv2:</strong> dualstack HTTP and WebSocket API (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34054">#34054</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/eec900e90f38f34f896b22cf36cb225fc9c13cc8">eec900e</a>)</li>
<li>update L1 CloudFormation resource definitions (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34064">#34064</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/9cb260266e92f45e40a19667e29ccf2decb3d2b8">9cb2602</a>)</li>
<li><strong>bedrock:</strong> support Amazon Nova Reel 1.1 (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34070">#34070</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/3da0c4d267dbb693ffc01b9fae69cebcb180cdec">3da0c4d</a>)</li>
<li>support L2 constructs for Amazon S3 Tables (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33599">#33599</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/2e95252fecbb1fec9874fd5af4b4bd6449d50471">2e95252</a>)</li>
<li><strong>pipelines:</strong> add <code>V2</code> pipeline type
support in L3 construct (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34005">#34005</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/994e95289b589596179553a5b9d7201155bd9ed1">994e952</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33995">#33995</a></li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>codepipeline:</strong> replace account root principal with
pipeline role in trust policy for cross-account actions (under feature
flag) (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34074">#34074</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/2d901f4e7bb982221e1a48a13666939140109d5a">2d901f4</a>)</li>
<li><strong>custom-resources:</strong> <code>AwsCustomResource</code>
assumed role session name may contain invalid characters (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34016">#34016</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/32b6b4d7fa99723efb667239fbe455ede43b92c6">32b6b4d</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/23260">#23260</a>
<a
href="https://redirect.github.com/aws/aws-cdk/issues/34011">#34011</a></li>
</ul>
<hr />
<h2>Alpha modules (2.189.0-alpha.0)</h2>
<h3>Features</h3>
<ul>
<li><strong>ec2-alpha:</strong> implement mapPublicIpOnLaunch prop in
SubnetV2 (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34057">#34057</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/836c5cf3e4c627f817e4dc8ed2af28a5bba54792">836c5cf</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/32159">#32159</a></li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>amplify:</strong> unable to re-run integ test due to missing
<code>status</code> field in <code>customRule</code> (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33973">#33973</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/6638c08d56afe7ecc4f23cff4cf334b887001e5e">6638c08</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33962">#33962</a></li>
</ul>
<h2>v2.188.0</h2>
<h3>Features</h3>
<ul>
<li>update L1 CloudFormation resource definitions (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33980">#33980</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/0923b5e82dd0c8da864f0c806f295fae270c22c1">0923b5e</a>)</li>
<li>update L1 CloudFormation resource definitions (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34029">#34029</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/be6210f246b97befcdc9446862e991071738008d">be6210f</a>)</li>
<li><strong>codepipeline:</strong> add usePipelineRoleForActions field
support in L2 (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33961">#33961</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/d8bbc1c3f8479ab5031b8684364735b9a6c31fa2">d8bbc1c</a>)</li>
<li><strong>codepipeline-actions:</strong> support
<code>ECRBuildAndPublish</code> action (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33375">#33375</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/c5cd679b2f979b9e51c7a071b18d930d3a475129">c5cd679</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33376">#33376</a></li>
<li><strong>codepipeline-actions:</strong> support
<code>InspectorEcrImageScanAction</code> and
<code>InspectorSourceCodeScanAction</code> actions (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33378">#33378</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/2dc8cc7f703ebcd61f2b5f4d20401a1ade788e7a">2dc8cc7</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33377">#33377</a></li>
<li><strong>cognito:</strong> v3.0 pre token generation trigger event
(<a
href="https://redirect.github.com/aws/aws-cdk/issues/33778">#33778</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/ea1436f85d036bddb9a96dd54f02a639c3aab212">ea1436f</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33733">#33733</a></li>
<li><strong>events-targets:</strong> support ApiGatewayV2 HttpApi (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33864">#33864</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/91a3076fb16369629a710ebc560c103a91c2ea20">91a3076</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/26649">#26649</a></li>
<li><strong>kinesisfirehose:</strong> support S3 file extension format
(<a
href="https://redirect.github.com/aws/aws-cdk/issues/33776">#33776</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/e314a9aa5d149704cc2abd30927a41d317a3ce6c">e314a9a</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/32154">#32154</a></li>
<li><strong>logs-destinations:</strong> support Amazon Data Firehose
logs destination (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33683">#33683</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/a8edf696e91c44cbda286889896464960dd03266">a8edf69</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/32038">#32038</a>
<a
href="https://redirect.github.com/aws/aws-cdk/issues/24766">#24766</a></li>
<li><strong>pipelines:</strong> actions can default to the pipeline
service role instead of a newly created role (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33991">#33991</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/2ebc51e694e85aa0d8e0401dbb1fc1037298eda5">2ebc51e</a>)</li>
<li><strong>rds:</strong> engine lifecycle support (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33902">#33902</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/c0f8d293df157cd196e2bd9fb569374d0535f471">c0f8d29</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33859">#33859</a></li>
</ul>
<h3>Bug Fixes</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.alpha.md">aws-cdk-lib's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<p>All notable changes to this project will be documented in this file.
See <a
href="https://github.com/conventional-changelog/standard-version">standard-version</a>
for commit guidelines.</p>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.198.0-alpha.0...v2.199.0-alpha.0">2.199.0-alpha.0</a>
(2025-05-27)</h2>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.197.0-alpha.0...v2.198.0-alpha.0">2.198.0-alpha.0</a>
(2025-05-22)</h2>
<h3>⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES</h3>
<ul>
<li><strong>amplify:</strong> A compute role is created when
<code>platform</code> is <code>Platform.WEB_COMPUTE</code> or
<code>Platform.WEB_DYNAMIC</code>.</li>
</ul>
<h3>Features</h3>
<ul>
<li><strong>amplify:</strong> add compute role support for Amplify app
(<a
href="https://redirect.github.com/aws/aws-cdk/issues/33962">#33962</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/7490b921aa2c464e32ad27064fa4b84571d5ba1a">7490b92</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/33882">#33882</a></li>
<li><strong>ec2:</strong> add i7i instance class (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34453">#34453</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/3fe8ab4bb100e23042f3d55d4a52bfc8cdbf495a">3fe8ab4</a>)</li>
</ul>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.196.1-alpha.0...v2.197.0-alpha.0">2.197.0-alpha.0</a>
(2025-05-20)</h2>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.196.0-alpha.0...v2.196.1-alpha.0">2.196.1-alpha.0</a>
(2025-05-19)</h2>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.195.0-alpha.0...v2.196.0-alpha.0">2.196.0-alpha.0</a>
(2025-05-15)</h2>
<h3>Features</h3>
<ul>
<li><strong>msk:</strong> support Kafka versions 3.9.x and 3.9.x Kraft
(<a
href="https://redirect.github.com/aws/aws-cdk/issues/34213">#34213</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/a1226db3164f885ab1bbf13a18697831cfde74d0">a1226db</a>)</li>
<li><strong>pipes-targets:</strong> add SNS (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34159">#34159</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/2f846b395cc5061363bd6def946a04740ac0139b">2f846b3</a>)</li>
<li><strong>s3tables:</strong> server-side encryption by customer
managed KMS key (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34229">#34229</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/488f0db714c20fcaf5dbdf682277a70c6a938d3f">488f0db</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>ec2:</strong> dual-stack vpc without private subnets creates
EgressOnlyInternetGateway (under feature flag) (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34437">#34437</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/35e818b4f86638b5fe6074705511d1eee16266d2">35e818b</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/30981">#30981</a></li>
<li><strong>ec2-alpha:</strong> fix resource id references and tags for
migration behind feature flag (<a
href="https://redirect.github.com/aws/aws-cdk/issues/34377">#34377</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/aa735341a8e95224a14241b5e1c5c5ba71de5022">aa73534</a>)</li>
</ul>
<h2><a
href="https://github.com/aws/aws-cdk/compare/v2.194.0-alpha.0...v2.195.0-alpha.0">2.195.0-alpha.0</a>
(2025-05-07)</h2>
<h3>⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES</h3>
<ul>
<li><strong>iot:</strong> By default,
<code>deviceDertificateAgeCheck</code> is automatically enabled.</li>
</ul>
<h3>Features</h3>
<ul>
<li><strong>iot:</strong> device certificate age check audit
configuration (<a
href="https://redirect.github.com/aws/aws-cdk/issues/33816">#33816</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/9ad383d5300c5d5f5a9d2552fbd541436570a404">9ad383d</a>)</li>
<li><strong>location:</strong> support L2 API Key Construct (<a
href="https://redirect.github.com/aws/aws-cdk/issues/32733">#32733</a>)
(<a
href="https://github.com/aws/aws-cdk/commit/d86787889dd49dce220324d141bf48e1bfa8fc3b">d867878</a>),
closes <a
href="https://redirect.github.com/aws/aws-cdk/issues/30684">#30684</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/aws/aws-cdk/commit/e7432ee4f8ae6f4ba000b1c1833188dddeb15624"><code>e7432ee</code></a>
chore(release): 2.189.1</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/b7f4bc7aee1d99b70e4d9d3cedea53e910ee37ef"><code>b7f4bc7</code></a>
fix(core): implicit Aspect applications do not override custom Aspect
applica...</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/dcd077fb04f6900fd92e127d92a777cc38cdf932"><code>dcd077f</code></a>
chore: update analytics metadata blueprints</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/b997bf125f0782d37fb8c99db0e0be09f4b10295"><code>b997bf1</code></a>
chore(release): 2.189.0</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/eec900e90f38f34f896b22cf36cb225fc9c13cc8"><code>eec900e</code></a>
feat(apigatewayv2): dualstack HTTP and WebSocket API (<a
href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/34054">#34054</a>)</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/9cb260266e92f45e40a19667e29ccf2decb3d2b8"><code>9cb2602</code></a>
feat: update L1 CloudFormation resource definitions (<a
href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/34064">#34064</a>)</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/2d901f4e7bb982221e1a48a13666939140109d5a"><code>2d901f4</code></a>
fix(codepipeline): replace account root principal with pipeline role in
trust...</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/3da0c4d267dbb693ffc01b9fae69cebcb180cdec"><code>3da0c4d</code></a>
feat(bedrock): support Amazon Nova Reel 1.1 (<a
href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/34070">#34070</a>)</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/b1e8879a800850efb130cb8aaaef596195de56f9"><code>b1e8879</code></a>
docs(pipelines): add link to developer guide on how to use docker
drop-in rep...</li>
<li><a
href="https://github.com/aws/aws-cdk/commit/1b98a41853c17dcce53c5bb7074011c8dd928fb3"><code>1b98a41</code></a>
docs(batch): add note on update fatgate compute environment (<a
href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/34022">#34022</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/aws/aws-cdk/commits/v2.189.1/packages/aws-cdk-lib">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=aws-cdk-lib&package-manager=npm_and_yarn&previous-version=2.183.0&new-version=2.189.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/swift-server/swift-aws-lambda-runtime/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2025-06-01 18:56:19 +02:00
Sébastien Stormacq 7edd4f8108 [core] Fix LocalServer failure to handle large body request (Issue #481) (#504)
Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/481
2025-06-01 18:31:02 +02:00
Konrad `ktoso` Malawski c7df9bcd8a Revert "[ci] : Remove deprecated options on unit-test action" (#513)
Reverts swift-server/swift-aws-lambda-runtime#510

I think the issue
https://github.com/swift-server/swift-aws-lambda-runtime/issues/509 that
caused this tests disabling has been resolved in Swift and would like to
confirm here as well.
2025-05-16 08:08:27 +02:00
Fabian Fett 5924fb6e75 Add inlinable where potentially usefull (#511)
Allow the compiler to specialize more code by applying `@inlinable` to
generic code.
2025-03-21 12:49:08 +01:00
Sébastien StormacqandFabian Fett 893909543b [ci] : Remove deprecated options on unit-test action (#510)
~~Attempt to fix CI~~

Remove usage of deprecated parameters on unit-test. 

- explicitly enable tests on nightly 6.0
- explicitly enable tests on nightly next
- explicitly enable tests on nightly main

At the time of this writing, this resolves to 

```
linux_6_0_container_image="swift:6.0-jammy"
linux_nightly_next_container_image="swiftlang/swift:nightly-6.1-jammy"
linux_nightly_main_container_image="swiftlang/swift:nightly-main-jammy"
```

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
2025-03-20 19:57:21 +01:00
Sébastien Stormacq 7322a3694a [plugin] Fix #505 : resources are not included in the archive on Linux (#506)
Resources are not included in the archive on Linux
 https://github.com/swift-server/swift-aws-lambda-runtime/issues/505

In addition, the script that checks if the resources are correctly
included in an archive when building on Linux is not working.
It failed to detected missing resources.

This patch fix both the plugin and the  CI script
2025-03-17 11:24:07 +01:00
Sébastien Stormacq c3380a0025 [tutorial] fix light image 03-04-01 (#502)
The light mode of image 03-04-01 was not used in the tutorial,
defaulting to dark background all the time.
This is fixed now
2025-03-17 10:56:10 +01:00
Sébastien Stormacq 0267ab1497 [example] Update cdk dependencies (#503)
Update CDK dependencies to address
https://github.com/swift-server/swift-aws-lambda-runtime/security/dependabot/2
2025-03-17 10:55:16 +01:00
Fabian Fett eb634fa9ab Remove unnecessary handler constraints (#499) 2025-03-07 10:31:49 +01:00
Fabian Fett 3ce0a873e3 Attach requestID to logger (#497) 2025-03-07 07:34:05 +01:00
Sébastien Stormacq ae06d59539 cleanup unused code (#498) 2025-03-07 06:48:00 +01:00
Sébastien Stormacq 8f10a6bbdd Fix CI error on Amazon S3 examples (#496)
When we include Traits, we changed the CI container from Swift 6.0
Amazon Linux to Swift 6.1 Nightly on Ubuntu.
This broke the CI because AWS SDK used in the `Examples/S3_AWSSDK`
example depends on `libssl-devel` which is not installed by default on
Jammy images.

This PR reverts back the container used to test all examples to an
Amazon Linux 2, but this time the 6.1-nightly version to allow to
compile the package traits.

This should address
https://github.com/swift-server/swift-aws-lambda-runtime/issues/494
2025-03-06 18:58:50 +01:00
Sébastien Stormacq bba711bd18 remove mentions of LambdaRuntImeCore (#495)
Cleanup code from mentions of `LambdaRuntimeCore`
2025-03-06 18:50:32 +01:00
Sébastien Stormacq bf02bcec9a declare user agent string only once (#493)
The user-agent string was repeated at 5+ different places in the source
code.
I defined it as a constant in the `ControlPlaneRequest` struct where
other similar constant have been defined and make sure the rest of the
code only uses that constant.

This should address
https://github.com/swift-server/swift-aws-lambda-runtime/issues/492
2025-03-06 16:52:42 +01:00
Fabian Fett 0a75e0f9cc Use package traits when using Swift 6.1 (#490) 2025-03-06 09:52:23 +01:00
Fabian Fett 03876f6eed [TestServer] Fix 488 and add simple test lambda (#489)
Fixes: #488
2025-03-04 08:20:06 +01:00
61cd5d54da [core] Add cancellation handling for nextInvocation() (#459)
Allow `LambdaChannelHandler.nextInvocation` to be cancelled.

### Motivation:

If we want to use ServiceLifecycle with the lambda runtime the lambda
runtime needs to be cancellable either via a ServiceLifecycle graceful
shutdown or via Task cancellation. To avoid bringing in the
ServiceLifecycle dependency this PR adds cancellation via Task
cancellation handler.

### Modifications:

Add `withTaskCancellationHandler` to nextInvocation which calls close on
cancel.
In `LambdaChannelHandler.channelInactive` resume continuation if state
is `waitingForNextInvocation`
Added `LambdaRuntimeClientTests.testCancellation`

### Result:

You can now cancel the runtime while it is waiting for the next
invocation.

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2025-02-27 17:03:41 +01:00
Fabian Fett 5de00c96c8 Fixes for Local Lambda Server (#486) 2025-02-27 16:08:39 +01:00
mattcorey 64b417926d Instructions for customizing the output path are incorrect (#484)
Instructions for customizing the output path are incorrect

### Motivation:

`displayHelpMessage` was incorrect - it claimed that the output path was
customizable via a `--output-directory` flag, but the code actually
looks for `--output-path`

### Modifications:

Changing the help message here, instead of the code, in case existing
projects already depend on `--output-path`

### Result:

`displayHelpMessage` will show the correct instructions
2025-02-26 23:42:27 +01:00
Adam Fowler 230eeb505c Update swift-nio to 2.81.0 (#483)
Update swift-nio to 2.81.0 to fix Swift 6 errors
2025-02-21 15:54:53 +01:00
Fabian Fett d7780480f2 Enable Swift 6 mode! (#482) 2025-02-20 16:17:23 +01:00
Josh 40e2291532 Quick typo fix. (#478)
Fixed a glaring typo in the opening section.

_[One line description of your change]_

### Motivation:

First thing I noticed when I started reading.

### Modifications:

Swapped two letters around.

### Result:

Peace and love for all humankind.
2025-02-16 13:40:46 +01:00
Paul ToffoloniandSébastien Stormacq 0777c80172 Add S3EventNotifier example (#477)
Add `S3EventNotifier` example

### Motivation:

There is currently no example regarding an AWS event triggered lambda,
such as a lambda that gets invoked on an S3 object upload. I've had to
look for a while to figure out that the `AWSLambdaEvents` exists and
that it can be used for that (had to find out via a Java example! 😜) so
I think this could be useful and a somewhat common use case

### Modifications:

Added an example of a lambda that gets triggered when an object gets
uploaded to an S3 bucket.

I have not described how to set up the actual S3 event in AWS because I
figured if you needed such a lambda you'd know, but I can describe that
too in the README if needed

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2025-02-11 17:22:12 +01:00
Sébastien Stormacq bd0ec62646 Remove platform dance in some examples (#476)
Remove `#if os` on some examples
2025-01-31 16:03:29 +00:00
Sébastien Stormacq 4d7d23b9c1 [examples] Update to Swift Lambda Events 1.0.0 (#475)
Now that the swift Lambda event library has been tagged 1.0.0, update
all the examples to use `from: "1.0.0"` instead of `main` branch
2025-01-29 22:12:47 +00:00
Sébastien Stormacq dbc2f98b62 add local testing instructions to hello world example (#474)
The local testing instruction are missing from the hello world example.
The format of the payload is not intuitive or trivial to guess. We need
to make it explicit
2025-01-29 13:26:56 +01:00
Sébastien Stormacq 7aa746f07e [core] LocalServer - report the error to the continuation (#471)
fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/470
2025-01-22 18:53:57 +01:00
Sébastien Stormacq 02821fe8f7 [test] Update mock server for Swift 6 compliance (#463)
Rewrite to MockServer (used only for performance testing and part of a
separate target) to comply with Swift 6 language mode and concurrency.

The new MockServer now uses `NIOAsyncChannel` and structured
concurrency.

Instead of adding support to
[MAX_REQUEST](https://github.com/swift-server/swift-aws-lambda-runtime/blob/11756b4e00ca75894826b41666bdae506b6eb496/Sources/AWSLambdaRuntimeCore/LambdaConfiguration.swift#L53)
environment variable like v1 did, we implemented support for
`MAX_REQUEST` environment variable in the MockServer itself. It closes
the connection and shutdown the server after servicing MAX_INVOCATIONS
Lambda requests). This allow to add the MAX_REQUEST penalty on the
MockServer and not on the LambdaRuntimeClient.

However, currently, the LambdaRuntimeClient does not shutdown when the
MockServer ends. I created
https://github.com/swift-server/swift-aws-lambda-runtime/issues/465 to
track this issue.

See https://github.com/swift-server/swift-aws-lambda-runtime/issues/377
2025-01-22 12:02:01 +00:00