Commit Graph

78 Commits

Author SHA1 Message Date
Erin Sparling d8aa38be78 [Example] Add APIGatewayV1 example (#569)
This PR adds an APIGateway V1 example, which differs slightly from the
existing [V2
example](https://github.com/swift-server/swift-aws-lambda-runtime/tree/main/Examples/APIGateway).

### Motivation:

While APIGatewayV2 has existed for a while, there are still some
scenarios where V1 is preferable (see [Choose between REST APIs and HTTP
APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html)
for more details). This PR adds a working example for the `Api` endpoint
type.

### Modifications:

Sources/main.swift
- Swapped APIGatewayRequestV2 and APIGatewayResponseV2 for their
unversioned counterparts (aka V1).

template.yaml
- Changed the Events name and corresponding `Type: Api` values.
- Added necessary additional properties to define a `GET` endpoint for
an `Api` endpoint.

Readme.md
- Updated the request and response example outputs.

### Result:

Now, an APIGateway and APIGatewayV1 example exist. 

> [!NOTE]
> It is the author's opinion that this new example should technically be
called `APIGateway` and the existing one should be renamed to
`APIGatewayV2` to keep consistent with the request and response type
naming conventions, but this is omitted from this request to be less
disruptive.
2025-09-26 12:13:48 +00:00
Sébastien Stormacq 02d483074d [Example] Use smaller containers in all examples (#571)
All the examples using SAM have a default Lambda runtime environment
memory size of 512Mb.

Lambda functions run in a microVM defined by its memory size. The memory
size influences the CPU power.
(see
https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html)

Increasing memory size increases runtime performance but also increase
costs.

As most of our examples are very simple and small functions, 512Mb
memory is not required. This PR reduces Lambda runtime execution
environment to 128Mb to reduce AWS costs.

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2025-09-26 10:10:12 +02:00
Sébastien Stormacq a1ab8df708 Update toolchain and doc for 6.2 (#564)
In preparation for the 2.0.0 GA release,

- Update `.swift-version`, `Package.swift` and all examples'
`package.swift` to Swift 6.2
- Update all references to `2.0.0-beta.3` to `2.0.0`. This includes the
doc and readme, but also the dependencies in the examples
`Package.swift`. This will temporary break the build of the examples,
until we tag v2.0.0. Note the CI will not be affected as its consumes
the local version of the library
- [CI] Use Swift-6.2-noble for all testing tasks
- Reinstate the script to generate the contributors list and update the
list
2025-09-23 21:12:33 +02:00
Sébastien Stormacq 1843cdcb3c [fix] The library must compile when no traits are enabled (#563)
Make required changed to ensure the library compiles when no traits are
enabled (fix:
https://github.com/swift-server/swift-aws-lambda-runtime/issues/562)

Add an example project that serves as test in the CI

### Motivation:

Recent changes introduced compilation errors when no traits are enabled.

### Modifications:

- `LambdaResponseStreamWriter.writeStatusAndHeaders()` moved to the
`FoundationSupport` directory where all classes and struct depending on
`Encodable` and `Decodable` are located, protected by `#if
FoundationJSONSupport`
- `LambdaRuntime.run()` method when ServiceLifeCycle is disabled in now
public (and therefore can not be `@inlinable` anymore)
- Add an example that disables all traits.
- Add this example to the CI 

### Result:

The Library now compiles when no default traits are enabled.
This is flagged `semver/major` because we change the public API
`LambdaRuntime.run()`
2025-09-16 11:05:45 +02:00
Sébastien Stormacq 303559d9ed Bump Amazon RDS version 19 PG 17 (#561)
Update SwiftServiceLifeCycle example to use Postgres 17 (PG 15 is going
to be deprecated on Amazon RDS)
2025-09-06 10:14:03 +02:00
Sébastien Stormacq 262c3b539a Revert streaming codable handler and provide it as an example, not an API (#549)
Revert streaming codable handler change and propose it as an example
instead of an handler API.

**Motivation:**
I made a mistake when submitting this PR 
https://github.com/swift-server/swift-aws-lambda-runtime/pull/532

It provides a Streaming+Codable handler that conveniently allows
developers to write handlers with `Codable` events for streaming
functions.

This is a mistake for three reasons:

- This is the only handler that assumes a Lamba Event structure as
input. I added a minimal `FunctionUrlRequest` and `FunctionURLResponse`
to avoid importing the AWS Lambda Events library. It is the first
handler to be event-specific. I don't think the runtime should introduce
event specific code.

- The handler only works when Lambda functions are exposed through
Function URLs. Streaming functions can also be invoke by API or CLI.

- The handler hides `FunctionURLRequest` details (HTTP headers, query
parameters, etc.) from developers

Developers were unaware they were trading flexibility for convenience

The lack of clear documentation about these limitations led to incorrect
usage patterns and frustrated developers who needed full request control
or were using other invocation methods.

**Modifications:**
- Removed the Streaming+Codable API from the library
- Moved the Streaming+Codable code to an example
- Added prominent warning section in the example README explaining the
limitations
- Clarified when to use Streaming+Codable vs ByteBuffer approaches
- Added decision rule framework to help developers choose the right
approach

**Result:**
The only API provided by the library to use Streaming Lambda functions
is exposing the raw `ByteBuffer` as input, there is no more `Codable`
handler for Streaming functions available in the API. I kept the
`Streaming+Codable` code an example.

After this change, developers have clear guidance on when to use each
streaming approach:

- Use streaming codable for Function URL + JSON payload + no request
details needed
- Use ByteBuffer StreamingLambdaHandler for full control, other
invocation methods, or request metadata access

This prevents misuse of the API and sets proper expectations about the
handler's capabilities and limitations, leading to better developer
experience and fewer integration issues.
2025-08-07 10:51:21 +02:00
Dmitry Platonov af7e9db838 [doc] Updated streaming response limit to 200 MB (#548)
### Motivation:
AWS Lambda response streaming now supports a default maximum response
payload size of 200 MB (increased from 20 MB). This update aligns the
documentation with the new AWS limits.

### Modifications:
- Updated readme.md: Changed "soft limit of 20 MB" to "default maximum
response payload size of 200 MB"
- Updated Examples/Streaming/README.md: Same change as above
- Updated terminology to match AWS official documentation

### Result:
Documentation now accurately reflects the current AWS Lambda streaming
response limits, enabling users to understand they can stream up to 200
MB payloads.

Reference:
https://aws.amazon.com/about-aws/whats-new/2025/07/aws-lambda-response-streaming-200-mb-payloads/
2025-08-06 13:35:06 +02:00
Sébastien Stormacq a5ff8e5c00 Add hummingbird Lambda example (#544)
Add Hummingbird web framework integration example for AWS Lambda

**Motivation:**
Developers using the Hummingbird web framework need a clear example of
how to integrate it with AWS Lambda. The existing examples focus on
basic Lambda handlers, but don't demonstrate how to use popular Swift
web frameworks like Hummingbird in a serverless context.

**Modifications:**
Added a complete Hummingbird Lambda example in Examples/Hummingbird/
including Package.swift with Hummingbird Lambda dependencies, main.swift
demonstrating router setup with API Gateway V2 integration, SAM template
for deployment, and comprehensive README documentation with build,
deploy, and usage instructions.

**Result:**
Developers can now easily create AWS Lambda functions using the
Hummingbird web framework, with a working example that shows router
configuration, API Gateway integration, and complete deployment workflow
using familiar Hummingbird syntax.
2025-08-05 15:13:13 +02: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"`
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 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 Stormacq 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 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 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
dependabot[bot] 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 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
Sébastien Stormacq bba711bd18 remove mentions of LambdaRuntImeCore (#495)
Cleanup code from mentions of `LambdaRuntimeCore`
2025-03-06 18:50:32 +01:00
Fabian Fett 0a75e0f9cc Use package traits when using Swift 6.1 (#490) 2025-03-06 09:52:23 +01:00
Paul Toffoloni 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 cda7c768dc update CDK dependencies (#469)
Just a `npm update` to remove dependabots warnings
2025-01-21 08:58:31 +01:00
Sébastien Stormacq 71d49b049e [plugin] support for resources packaging on ubuntu (#467)
When including resources in the package and packaging on Ubuntu,
`FileManager` throws a FilePermission error. The docker daemon runs as
root and files to be copied are owned by `root` while the archiver runs
as the current user (`ubuntu` on EC2 Ubuntu). The `FileManager` manages
to copy the files but throws an error after the copy. We suspect the
`FileManager` to perform some kind of operation after the copy and it
fails because of the `root` permission of the files.

See
https://github.com/swift-server/swift-aws-lambda-runtime/issues/449#issuecomment-2595978246
for a description of the problem.

This PR contains code to reproduce the problem, a very simple
workaround, and an integration test.
The workaround consists of 
- trapping all errors
- verify if the error is the permission error (Code = 513)
- verify if the files have been copied or not 
- if the two above conditions are met, ignore the error, otherwise
re-throw it

I would rather prefer a solution that solves the root cause rather than
just ignoring the error.
We're still investigating the root cause (see [this
thread](https://forums.swift.org/t/filemanager-copyitem-on-linux-fails-after-copying-the-files/77282)
on the Swift Forum and this issue on Swift Foundation
https://github.com/swiftlang/swift-foundation/issues/1125
2025-01-21 08:06:51 +01:00
Sébastien Stormacq 3fa610d7f5 [examples] Simplify examples's Package.swift (#454)
remove the platform dance on all examples.
2025-01-08 14:31:34 +00:00
Sébastien Stormacq 051029fc0f [examples] Add an example of an APIGateway Lambda Authorizer (#453)
Add an example of an APIGateway Lambda Authorizer

### Motivation:

Lambda Authorizers allow developers to write custom logic to validate
HTTP REST requests.
This example shows how to write a Lambda Authorizer in Swift and how to
configure an API Gateway to use a Lambda Authorizer.

This example use a SAM template to deploy the resources.

### Modifications:

- Add `Examples/APIGateway+LambdaAuthorizer` directory with the source
code, a `template.yaml`, and a `README` file.
- Add a reference to the new example in `Examples/README`
- Modify CI to build the new example 

### Result:

There is a new example showing how to develop a Lambda authorizer in
Swift and how to attach it to an APIGateway with SAM
2025-01-06 16:44:13 +01:00
Sébastien Stormacq 2669009d3b Update the tutorial for v2 (#450)
Update the text, code sample, and screenshots for runtime v2

Address
https://github.com/swift-server/swift-aws-lambda-runtime/issues/371
2025-01-04 10:54:37 +01:00
Sébastien Stormacq 38cc01a000 [example] Update testing doc for clarity and remove some typos (#445) 2024-12-25 20:41:00 +01:00
Sébastien Stormacq f65ec32c4d [doc] add a deployment guide and update the readme (#432)
As discussed with @0xTim 
This PR 
- adds a minimal example of deployment using SAM in the README 
- adds a `Deployment.md` Swift Docc file to cover deployment with the
AWS console, CLI, SAM, and CDK. It mentions and contains a call to
contributions to further examples for third-party tools such as the
Serverless Framework, Terraform, or Pulumi.
2024-12-25 07:43:51 +01:00
Sébastien Stormacq cef85b9fe8 [examples] add an example project to show test strategies (#438)
This new example project show four testing strategies for Swift Lambda
function

- Unit testing the business logic (not specific to Swift Lambda) 
- Integration testing the handler method 
- Local invocation with the Swift Lambda Runtime 
- Local invocation with SAM 

**[IMPORTANT]**
To allow testing the handler, I had to change visibility of a method in
the Runtime project. This method is clearly marked for testing only, so
it should not be a problem. Happy to read feedback and discuss however.
2024-12-25 07:43:20 +01:00
Sébastien Stormacq e80fcf766e [examples] Update APIGateway example with the new APIGatewayResponse initializer (#437)
After the merge of
https://github.com/swift-server/swift-aws-lambda-events/pull/86
I updated the `APIGatewayV2Response` example to use the new initializer
2024-12-24 08:40:46 +01:00
Sébastien Stormacq e5404c95cb [examples] Fix path settings in the examples' Package.swift (#439)
All the `Package.swift` files from the examples use `path: "."` instead
of `path: "Sources"` which triggers error messages when users add a
`Tests` directory.
2024-12-22 07:36:32 +01:00
Sébastien Stormacq 18660fcdd1 [examples] Add CDK deployment example (#431)
added an example showing how to deploy with the CDK
This code is the basis for the upcoming CDK section in the deployment
guide
2024-12-21 10:39:13 +01:00
Tobias 25eb6e16de Explicitly only use FoundationEssentials where possible (#436)
We want that the runtime only depends on `FoundationEssentials` where
available (ie. on linux) to ensure small binary size.

### Motivation:

Smaller binary size is good for lambda deployment and cold-start times.
The runtime should only depend on `FoundationEssentials`.

### Modifications:

- replace `import Foundation` with `import FoundationEssentials` if
`FoundationEssentials` is available.
- I also applied the same treatment to tests to ensure that catch error
where tests run on linux and we use API that is only available in
`Foundation` which easily happens when you develop on macOS (where
always full `Foundation` is available).

### Result:

This should allow builds without linking full `Foundation`.
2024-12-20 15:21:33 +01:00
Sébastien Stormacq c22f5271a0 add HelloJSON example + README (#424)
* add HelloJSON example + README

* multiple corrections of typos and grammatical errors

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2024-11-13 13:53:19 +01:00
Sébastien Stormacq 54fd25bdad Add example and README for a streaming Lambda function (#415)
* add streaming example and doc

* add streaming example to CI

* fix soundness

* remove unused files

* correct usage of zsh env var

* typo

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* typo

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* add comments

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* typo

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* add an example README with common sections + link to each example

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2024-11-07 14:55:37 +01:00
Sébastien Stormacq ca82709a9b Add an example and README for background tasks (#418)
* add an example for background tasks

* swift-format

* add CI

* add background task section in the main readme

* minor formatting changes
2024-11-07 11:33:34 +01:00
Sébastien Stormacq 4992ba5bd8 change flag name from --allow-network-access to --allow-network-connections as documented by SPM (#407) 2024-10-18 14:51:23 +02:00
Franz Busch 59dd68adab [CI] Adopt soundess workflow from swiftlang (#405) 2024-10-11 15:49:34 +02:00
Sébastien Stormacq b4673d264b Add AWS SDK and Soto examples (#396)
* add aws sdk example

* add soto example

* use amazonlinux docker image instead of ubuntu

* dynamically add runtime dependency based on env var

* remove import of Foundation.ProcessInfo

* workaround https://github.com/actions/checkout/issues/1487
2024-10-10 13:08:31 +02:00
Sébastien Stormacq f7584d1257 add docker fine grained permission to the plugin (#391)
* add docker fine grained permission to the plugin

* swift-format
2024-10-08 14:10:53 +02:00
Sébastien Stormacq db17a62e38 Restructure Examples folder (#387)
* Restructure Examples folder

* add README

* remove v1 examples

* swift format
2024-10-08 11:07:47 +02:00
Jack Rosen 426e658414 Add Support For Copying All Resources Into Final Executable (#386)
* Add Support For Copying All Resources Into Final Executable

* Run formatter

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-10-08 10:43:17 +02:00
Franz Busch ab8166a39d [CI] Add GHA CI and release flow (#340)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
2024-08-26 16:36:07 +02:00
Sébastien Stormacq 8676c8933a apply swiftformat (#342)
* apply swiftformat

* update dep on Swift Docc to v1.3.0

* force usage of swift docc plugin 1.3.0
2024-08-26 12:25:41 +02:00
Camden Fullmer 35e0919ed2 Add support for resources when packaging using the SwiftPM plugin (#333)
* Add support for resources when packaging using the SwiftPM plugin.

* Copy the resources directory to the working directory instead of recreating the directroy structure.

* Add resource packaging example.

* Use the bundle's url function to locate the file url.

* Fix year for soundness check.

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-08-05 17:51:21 +02:00
tomer doron 3b72f6a6cf improve examples (#292)
motivation: examples can be confusing since they use relative path to the library for CI purposes

changes:
* update examples to use the library URL, expect when env variable is set for CI purposes
* rename docker compose job to test-examples since it is more accurate
2023-03-12 11:23:41 -07:00
tomer doron c915322eca API Refactoring (#273)
motivation: define stable API in preperation 1.0 release

changes:
* require swift 5.7, remove redundant backwards compatibility code
* make LambdaHandler, EventLoopLambdaHandler, and ByteBufferLambdaHandler disjointed protocols to reduce API surface area
* create coding wrappers for LambdaHandler and EventLoopLambdaHandler to provide bridge to ByteBufferLambdaHandler
* reuse output ByteBuffer to reduce allocations
* add new SimpleLambdaHandler with no-op initializer for simple lambda use cases
* update callsites and tests
* update examples

Co-authored-by: Yim Lee <yim_lee@apple.com>
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2022-11-09 10:08:36 -08:00
Bill 20978cc462 Add special Deployment instructions for the Mac M1 (#263) 2022-05-09 10:19:30 -07:00