Skip to content

Commit 81f8d27

Browse files
tomerdyim-leefabianfett
authored
packaging plugin (#254)
motivation: add an easy wasy for lambda users to package their lambda and upload it to AWS changes: * add SwiftPM plugin to package the lambda as zipfile, with the verb "archive" * use docker to build and package the lambda(s) on macOS and non-amazonlinux * build directly on when on amazonlinux, zip correctly Co-authored-by: Yim Lee <yim_lee@apple.com> Co-authored-by: Fabian Fett <fabianfett@apple.com>
1 parent 20978cc commit 81f8d27

File tree

3 files changed

+525
-1
lines changed

3 files changed

+525
-1
lines changed

Package@swift-5.6.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// swift-tools-version:5.6
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-aws-lambda-runtime",
7+
products: [
8+
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
9+
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
10+
// this has all the main functionality for lambda and it does not link Foundation
11+
.library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]),
12+
// plugin to package the lambda, creating an archive that can be uploaded to AWS
13+
.plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]),
14+
// for testing only
15+
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
16+
],
17+
dependencies: [
18+
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.33.0")),
19+
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
20+
.package(url: "https://github.com/swift-server/swift-backtrace.git", .upToNextMajor(from: "1.2.3")),
21+
],
22+
targets: [
23+
.target(name: "AWSLambdaRuntime", dependencies: [
24+
.byName(name: "AWSLambdaRuntimeCore"),
25+
.product(name: "NIOCore", package: "swift-nio"),
26+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
27+
]),
28+
.target(name: "AWSLambdaRuntimeCore", dependencies: [
29+
.product(name: "Logging", package: "swift-log"),
30+
.product(name: "Backtrace", package: "swift-backtrace"),
31+
.product(name: "NIOHTTP1", package: "swift-nio"),
32+
.product(name: "NIOCore", package: "swift-nio"),
33+
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
34+
.product(name: "NIOPosix", package: "swift-nio"),
35+
]),
36+
.plugin(
37+
name: "AWSLambdaPackager",
38+
capability: .command(
39+
intent: .custom(
40+
verb: "archive",
41+
description: "Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions."
42+
)
43+
)
44+
),
45+
.testTarget(name: "AWSLambdaRuntimeCoreTests", dependencies: [
46+
.byName(name: "AWSLambdaRuntimeCore"),
47+
.product(name: "NIOTestUtils", package: "swift-nio"),
48+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
49+
]),
50+
.testTarget(name: "AWSLambdaRuntimeTests", dependencies: [
51+
.byName(name: "AWSLambdaRuntimeCore"),
52+
.byName(name: "AWSLambdaRuntime"),
53+
]),
54+
// testing helper
55+
.target(name: "AWSLambdaTesting", dependencies: [
56+
.byName(name: "AWSLambdaRuntime"),
57+
.product(name: "NIO", package: "swift-nio"),
58+
]),
59+
.testTarget(name: "AWSLambdaTestingTests", dependencies: ["AWSLambdaTesting"]),
60+
// for perf testing
61+
.executableTarget(name: "MockServer", dependencies: [
62+
.product(name: "NIOHTTP1", package: "swift-nio"),
63+
.product(name: "NIO", package: "swift-nio"),
64+
]),
65+
]
66+
)

0 commit comments

Comments
 (0)