Skip to content

Commit ed1dba9

Browse files
committed
add some clarifications
1 parent b1f5bef commit ed1dba9

File tree

1 file changed

+37
-31
lines changed

1 file changed

+37
-31
lines changed

Plugins/Documentation.docc/Proposals/0001-v2-plugins.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ As a source of inspiration, we looked to the Rust community, which created Cargo
2222

2323
### Current Limitations
2424

25-
The current version of `swift-aws-lambda-runtime` does not provide any support for project scaffolding or deployment of Lambda functions. This makes it difficult for Swift developers new to AWS and Lambda, or AWS Professionals new to Swift, to get started.
25+
The current version of `swift-aws-lambda-runtime` does not provide any support for project **scaffolding** or **deployment** of Lambda functions. This makes it difficult for Swift developers new to AWS and Lambda, or AWS Professionals new to Swift, to get started.
2626

2727
The main limitations of the current version of the `archive` plugin are as follows:
2828

@@ -43,15 +43,13 @@ We may consider additional plugins in a future release. For example, we could co
4343

4444
## Detailed Solution
4545

46-
### Dependencies
47-
48-
One of the design objective of the Swift AWS Lambda Runtime is to minimize its dependencies on other libraries. We will strive to keep the dependencies of the plugins to a minimum.
46+
The proposed solution consists of three new plugins: `lambda-init`, `lambda-build`, and `lambda-deploy`. These plugins will assist developers in creating, building, packaging, and deploying Lambda functions.
4947

5048
### Create a New Project (lambda-init)
5149

52-
The `lambda-init` plugin will assist developers in creating a new Lambda project from scratch. The plugin will scaffold the project code. It will create a ready-to-deploy `main.swift` file containing a simple Lambda function. The plugin will allow users to choose from a selection of basic templates, such as a simple "Hello World" Lambda function or a function invoked by a URL.
50+
The `lambda-init` plugin will assist developers in creating a new Lambda project from scratch. The plugin will scaffold the project code. It will create a ready-to-build `main.swift` file containing a simple Lambda function. The plugin will allow users to choose from a selection of basic templates, such as a simple "Hello World" Lambda function or a function invoked by a URL.
5351

54-
The plugin cannot be invoked without the required dependencies installed in `Package.swift`. The process of creating a new project will consist of three steps and four commands, all executable from the command line:
52+
The plugin cannot be invoked without the required dependency on `swift-aws-lambda-runtime` project being configured in `Package.swift`. The process of creating a new project will consist of three steps and four commands, all executable from the command line:
5553

5654
```bash
5755
# Step 1: Create a new Swift executable package
@@ -92,7 +90,7 @@ The `lambda-build` plugin will assist developers in building and packaging their
9290

9391
We also propose to automatically strip the binary of debug symbols to reduce the size of the ZIP file. Our tests showed that this can reduce the size by up to 50%. An option to disable stripping will be provided.
9492

95-
The `lambda-build` plugin is similar to the existing `archive` plugin. We propose to keep the same interface to facilitate migration of existing projects. If technically feasible, we will also consider keeping the `archive` plugin as an alias to the `lambda-build` plugin.
93+
The `lambda-build` plugin is similar to the existing `archive` plugin. We propose to keep the same interface to facilitate migration of existing projects and CI chains. If technically feasible, we will also consider keeping the `archive` plugin as an alias to the `lambda-build` plugin.
9694

9795
The plugin interface is based on the existing `archive` plugin, with the addition of the `--no-strip` and `--cross-compile` options:
9896

@@ -101,15 +99,17 @@ OVERVIEW: A SwiftPM plugin to build and package your Lambda function.
10199
102100
REQUIREMENTS: To use this plugin, Docker must be installed and running.
103101
104-
USAGE: swift package --allow-network-connections docker archive
105-
[--help] [--verbose]
106-
[--output-directory <path>]
107-
[--products <list of products>]
108-
[--configuration debug | release]
109-
[--swift-version <version>]
110-
[--base-docker-image <docker_image_name>]
111-
[--disable-docker-image-update]
112-
102+
USAGE: swift package archive
103+
[--help] [--verbose]
104+
[--output-directory <path>]
105+
[--products <list of products>]
106+
[--configuration debug | release]
107+
[--swift-version <version>]
108+
[--base-docker-image <docker_image_name>]
109+
[--disable-docker-image-update]
110+
[--no-strip]
111+
[--cross-compile <value>]
112+
[--allow-network-connections docker]
113113
114114
OPTIONS:
115115
--output-directory <path> The path of the binary package.
@@ -125,14 +125,19 @@ OPTIONS:
125125
(default: swift-<version>:amazonlinux2)
126126
This parameter cannot be used with --swift-version.
127127
This parameter cannot be used with a value other than Docker provided to --cross-compile.
128-
--disable-docker-image
128+
--disable-docker-image-update Do not update the Docker image before building.
129+
--no-strip Do not strip the binary of debug symbols.
130+
--cross-compile <value> Cross-compile the binary using the specified method.
131+
(default: docker) Accepted values are: docker, swift-static-sdk, custom-sdk
129132
```
130133

131134
### Deploy (lambda-deploy)
132135

133136
The `lambda-deploy` plugin will assist developers in deploying their Lambda function to AWS. It will handle the deployment process, including creating the IAM role, the Lambda function itself, and optionally configuring a Lambda function URL.
134137

135-
The plugin will not require any additional dependencies. It will interact with the AWS REST API directly, without using the AWS SDK fro Swift or Soto. Users will need to provide AWS access key and secret access key credentials. The plugin will attempt to locate these credentials in standard locations, such as environment variables or the `~/.aws/credentials` file.
138+
The plugin will not depends on nay third-party library. It will interact directly with the AWS REST API, without using the AWS SDK fro Swift or Soto.
139+
140+
Users will need to provide AWS access key and secret access key credentials. The plugin will attempt to locate these credentials in standard locations, such as environment variables or the `~/.aws/credentials` file.
136141

137142
The plugin supports deployment through either the REST and Base64 payload or by uploading the code to a temporary S3 bucket. Refer to [the `Function Code` section](https://docs.aws.amazon.com/lambda/latest/api/API_FunctionCode.html) of the [CreateFunction](https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html) API for more details.
138143

@@ -152,6 +157,9 @@ OVERVIEW: A SwiftPM plugin to deploy a Lambda function.
152157
153158
USAGE: swift package lambda-deploy
154159
[--with-url]
160+
[--region <value>]
161+
[--iam-role <value>]
162+
[--delete]
155163
[--help] [--verbose]
156164
157165
OPTIONS:
@@ -168,11 +176,13 @@ OPTIONS:
168176

169177
### Dependencies
170178

171-
Minimizing dependencies is a key priority for the plugins. We aim to avoid including unnecessary dependencies, such as the AWS SDK for Swift or Soto, for the `lambda-deploy` plugin.
179+
One of the design objective of the Swift AWS Lambda Runtime is to minimize its dependencies on other libraries.
172180

173-
Four essential dependencies have been identified for the plugins:
181+
Therefore, minimizing dependencies is a key priority for the new plugins. We aim to avoid including unnecessary dependencies, such as the AWS SDK for Swift or Soto, for the `lambda-deploy` plugin.
174182

175-
* an argument parser
183+
Four essential dependencies have been identified to implement the plugins:
184+
185+
* an command line argument parser
176186
* an HTTP client
177187
* a library to sign AWS requests
178188
* a library to calculate HMAC-SHA256 (used in the AWS signing process)
@@ -181,7 +191,7 @@ These functionalities can be incorporated by vending source code from other proj
181191

182192
**Argument Parser:**
183193

184-
* We will leverage the `ArgumentExtractor` from the `swift-package-manager` project ([https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackagePlugin/ArgumentExtractor.swift](https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackagePlugin/ArgumentExtractor.swift)). This is a simple argument parser used by the Swift Package Manager. The relevant files will be copied into the plugin.
194+
* We propose to leverage the `ArgumentExtractor` from the `swift-package-manager` project ([https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackagePlugin/ArgumentExtractor.swift](https://github.com/swiftlang/swift-package-manager/blob/main/Sources/PackagePlugin/ArgumentExtractor.swift)). This is a simple argument parser used by the Swift Package Manager. The relevant files will be copied into the plugin.
185195

186196
**HTTP Client:**
187197

@@ -199,7 +209,7 @@ These functionalities can be incorporated by vending source code from other proj
199209

200210
The dependencies will be vendored within the plugin and will not be listed as dependencies in the `Package.swift` file.
201211

202-
The following files will be copied into the plugin, without modifications from their original projects:
212+
If we follow that plan, the following files will be copied into the plugin, without modifications from their original projects:
203213

204214
```text
205215
Sources/AWSLambdaPluginHelper/Vendored
@@ -235,7 +245,7 @@ Sources/AWSLambdaPluginHelper/Vendored
235245

236246
### Implementation
237247

238-
SwiftPM plugin can not share code within sources files or using a shared Library target. The recommended way to share code between plugins is to create an executable target to implement the plugin functionalities and to implement the plugin as a thin wrapper that invokes the executable target.
248+
SwiftPM plugins from a same project can not share code in between sources files or using a shared Library target. The recommended way to share code between plugins is to create an executable target to implement the plugin functionalities and to implement the plugin as a thin wrapper that invokes the executable target.
239249

240250
We propose to add an executable target and three plugins to the `Package.swift` file of the `swift-aws-lambda-runtime` package.
241251

@@ -249,11 +259,7 @@ let package = Package(
249259
// The runtime library targets
250260
//
251261

252-
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
253-
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
254-
255-
// this has all the main functionality for lambda and it does not link Foundation
256-
.library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]),
262+
// ... unchanged ...
257263

258264
//
259265
// The plugins
@@ -430,9 +436,9 @@ In addition to the proposed solution, we evaluated the following alternatives:
430436

431437
We considered using a VSCode extension, such as the `vscode-aws-lambda-swift-sam` extension ([https://github.com/swift-server-community/vscode-aws-lambda-swift-sam](https://github.com/swift-server-community/vscode-aws-lambda-swift-sam)), to scaffold new Lambda projects.
432438

433-
This extension creates a new Lambda project from scratch, including the project structure and dependencies. It provides a ready-to-deploy `main.swift` file with a simple Lambda function and allows users to choose from basic templates, such as "Hello World" or an OpenAPI-based function. However, the extension relies on the AWS CLI and SAM CLI for deployment. It is only available in the Visual Studio Code Marketplace.
439+
This extension creates a new Lambda project from scratch, including the project structure and dependencies. It provides a ready-to-build `main.swift` file with a simple Lambda function and allows users to choose from basic templates, such as "Hello World" or an OpenAPI-based Lambda function. However, the extension relies on the AWS CLI and SAM CLI for deployment. It is only available in the Visual Studio Code Marketplace.
434440

435-
While the extension offers a user-friendly graphical interface, it does not align well with our goals of simplicity for first-time users and minimal dependencies. Users would need to install VSCode, the extension itself, the AWS CLI, and the SAM CLI before getting started.
441+
While the extension offers a user-friendly graphical interface, it does not align well with our goals of simplicity for first-time users and minimal dependencies. Users would need to install and configure VSCode, the extension itself, the AWS CLI, and the SAM CLI before getting started.
436442

437443
2. **Deployment DSL with AWS SAM:**
438444

0 commit comments

Comments
 (0)