Skip to content

Commit 945d0d4

Browse files
authored
Merge branch 'main' into sebsto/new-plugin-proposal
2 parents 5444714 + ae06d59 commit 945d0d4

File tree

136 files changed

+959
-866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+959
-866
lines changed

.github/workflows/integration_tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ on:
3838
required: true
3939
matrix_linux_swift_container_image:
4040
type: string
41-
description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image."
42-
default: "swift:amazonlinux2"
41+
description: "Container image for the matrix job. Defaults to matching latest Swift 6.1 Amazon Linux 2 image."
42+
default: "swiftlang/swift:nightly-6.1-amazonlinux2"
4343

4444
## We are cancelling previously triggered workflow runs
4545
concurrency:
@@ -59,7 +59,6 @@ jobs:
5959
# We are using only one Swift version
6060
swift:
6161
- image: ${{ inputs.matrix_linux_swift_container_image }}
62-
swift_version: "6.0.3-amazonlinux2"
6362
container:
6463
image: ${{ matrix.swift.image }}
6564
steps:
@@ -93,7 +92,6 @@ jobs:
9392
- name: Run matrix job
9493
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
9594
env:
96-
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
9795
COMMAND: ${{ inputs.matrix_linux_command }}
9896
EXAMPLE: ${{ matrix.examples }}
9997
run: |

.github/workflows/pull_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
license_header_check_project_name: "SwiftAWSLambdaRuntime"
1313
shell_check_enabled: true
1414
python_lint_check_enabled: true
15-
api_breakage_check_container_image: "swift:6.0-noble"
15+
api_breakage_check_container_image: "swiftlang/swift:nightly-6.1-jammy"
1616
docs_check_container_image: "swift:6.0-noble"
17-
format_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
17+
format_check_container_image: "swiftlang/swift:nightly-6.1-jammy"
1818
yamllint_check_enabled: true
1919

2020
unit-tests:
@@ -36,7 +36,7 @@ jobs:
3636
# We pass the list of examples here, but we can't pass an array as argument
3737
# Instead, we pass a String with a valid JSON array.
3838
# The workaround is mentioned here https://github.com/orgs/community/discussions/11692
39-
examples: "[ 'APIGateway', 'APIGateway+LambdaAuthorizer', 'BackgroundTasks', 'HelloJSON', 'HelloWorld', 'ResourcesPackaging', 'S3_AWSSDK', 'S3_Soto', 'Streaming', 'Testing', 'Tutorial' ]"
39+
examples: "[ 'APIGateway', 'APIGateway+LambdaAuthorizer', 'BackgroundTasks', 'HelloJSON', 'HelloWorld', 'ResourcesPackaging', 'S3EventNotifier', 'S3_AWSSDK', 'S3_Soto', 'Streaming', 'Testing', 'Tutorial' ]"
4040
archive_plugin_examples: "[ 'HelloWorld', 'ResourcesPackaging' ]"
4141
archive_plugin_enabled: true
4242

.github/workflows/scripts/integration_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ log() { printf -- "** %s\n" "$*" >&2; }
1919
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
2020
fatal() { error "$@"; exit 1; }
2121

22+
SWIFT_VERSION=$(swift --version)
2223
test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset"
2324
test -n "${COMMAND:-}" || fatal "COMMAND unset"
2425
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"

.spi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [AWSLambdaRuntimeCore, AWSLambdaRuntime]
4+
- documentation_targets: [AWSLambdaRuntime]

Examples/APIGateway+LambdaAuthorizer/Package.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import PackageDescription
55
// needed for CI to test the local version of the library
66
import struct Foundation.URL
77

8-
#if os(macOS)
9-
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)]
10-
#else
11-
let platforms: [PackageDescription.SupportedPlatform]? = nil
12-
#endif
13-
148
let package = Package(
159
name: "swift-aws-lambda-runtime-example",
1610
platforms: [.macOS(.v15)],
@@ -21,7 +15,7 @@ let package = Package(
2115
dependencies: [
2216
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
2317
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"),
24-
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"),
18+
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "1.0.0"),
2519
],
2620
targets: [
2721
.executableTarget(

Examples/APIGateway/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
dependencies: [
1515
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
1616
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"),
17-
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"),
17+
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "1.0.0"),
1818
],
1919
targets: [
2020
.executableTarget(

Examples/CDK/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
dependencies: [
1515
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
1616
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"),
17-
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"),
17+
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "1.0.0"),
1818
],
1919
targets: [
2020
.executableTarget(

Examples/HelloJSON/Package.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// swift-tools-version:6.0
1+
// swift-tools-version:6.1
22

33
import PackageDescription
44

55
// needed for CI to test the local version of the library
66
import struct Foundation.URL
77

8-
#if os(macOS)
9-
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)]
10-
#else
11-
let platforms: [PackageDescription.SupportedPlatform]? = nil
12-
#endif
13-
148
let package = Package(
159
name: "swift-aws-lambda-runtime-example",
16-
platforms: platforms,
10+
platforms: [.macOS(.v15)],
1711
products: [
1812
.executable(name: "HelloJSON", targets: ["HelloJSON"])
1913
],
2014
dependencies: [
2115
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
22-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
16+
.package(
17+
url: "https://github.com/swift-server/swift-aws-lambda-runtime.git",
18+
branch: "ff-package-traits",
19+
traits: [
20+
.trait(name: "FoundationJSONSupport")
21+
]
22+
)
2323
],
2424
targets: [
2525
.executableTarget(

Examples/HelloWorld/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@ The handler is `(event: String, context: LambdaContext)`. The function takes two
1212

1313
The function return value will be encoded as your Lambda function response.
1414

15+
## Test locally
16+
17+
You can test your function locally before deploying it to AWS Lambda.
18+
19+
To start the local function, type the following commands:
20+
21+
```bash
22+
swift run
23+
```
24+
25+
It will compile your code and start the local server. You know the local server is ready to accept connections when you see this message.
26+
27+
```txt
28+
Building for debugging...
29+
[1/1] Write swift-version--644A47CB88185983.txt
30+
Build of product 'MyLambda' complete! (0.31s)
31+
2025-01-29T12:44:48+0100 info LocalServer : host="127.0.0.1" port=7000 [AWSLambdaRuntime] Server started and listening
32+
```
33+
34+
Then, from another Terminal, send your payload with `curl`. Note that the payload must be a valid JSON string. In the case of this function that accepts a simple String, it means the String must be wrapped in between double quotes.
35+
36+
```bash
37+
curl -d '"seb"' http://127.0.0.1:7000/invoke
38+
"Hello seb"
39+
```
40+
41+
> [!IMPORTANT]
42+
> The local server is only available in `DEBUG` mode. It will not start with `swift -c release run`.
43+
1544
## Build & Package
1645

1746
To build & archive the package, type the following commands.

Examples/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ This directory contains example code for Lambda functions.
2828

2929
- **[HelloWorld](HelloWorld/README.md)**: a simple Lambda function (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)).
3030

31+
- **[S3EventNotifier](S3EventNotifier/README.md)**: a Lambda function that receives object-upload notifications from an [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) bucket.
32+
3133
- **[S3_AWSSDK](S3_AWSSDK/README.md)**: a Lambda function that uses the [AWS SDK for Swift](https://docs.aws.amazon.com/sdk-for-swift/latest/developer-guide/getting-started.html) to invoke an [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) API (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)).
3234

3335
- **[S3_Soto](S3_Soto/README.md)**: a Lambda function that uses [Soto](https://github.com/soto-project/soto) to invoke an [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) API (requires [AWS SAM](https://aws.amazon.com/serverless/sam/)).
@@ -64,4 +66,4 @@ To obtain these keys, you need an AWS account:
6466

6567
4. **(Optional) Generate Temporary Security Credentials**: If you’re using temporary credentials (which are more secure for short-term access), use AWS Security Token Service (STS). You can call the `GetSessionToken` or `AssumeRole` API to generate temporary credentials, including a session token.
6668

67-
With these in hand, you can use AWS SigV4 to securely sign your requests and interact with AWS services from your Swift app.
69+
With these in hand, you can use AWS SigV4 to securely sign your requests and interact with AWS services from your Swift app.

0 commit comments

Comments
 (0)