Skip to content

Commit ca4d1c2

Browse files
committed
update README to reflect latest changes
1 parent 1d720a2 commit ca4d1c2

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

Plugins/AWSLambdaDeployer/README.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ SAM is already broadly adopted, well maintained and documented. It does the job.
2222

2323
I added two targets to `Package.swift` :
2424

25-
- `AWSLambdaDeployer` is the plugin itself. I followed the same structure and code as the `archive` plugin (similar configuration and shell code).
25+
- `AWSLambdaDeployer` is the plugin itself. I followed the same structure and code as the `archive` plugin. Common code between the two plugins has been isolated in a shared `PluginUtils.swift` file. Because of [a limitation in the current Swift package systems for plugins](https://forums.swift.org/t/difficulty-sharing-code-between-swift-package-manager-plugins/61690/11), I symlinked the file from one plugin directory to the other.
2626

2727
- `AWSLambdaDeploymentDescriptor` is a shared library that contains the data structures definition to describe and to generate a JSON SAM deployment file. It models SAM resources such as a Lambda functions and its event sources : HTTP API and SQS queue. It contains the logic to generate the SAM deployment descriptor, using minimum information provided by the Swift lambda function developer. At the moment it provides a very minimal subset of the supported SAM configuration. I am ready to invest more time to cover more resource types and more properties if this proposal is accepted.
2828

29-
I added a new Example project : `SAM`. It contains two Lambda functions, one invoked through HTTP API, and one invoked through SQS. It also defines shared resources such as SQS Queue and a DynamoDB Table. It contains minimum code to describe the required HTTP API and SQS code and to allow `AWSLambdaDeploymentDescriptor` to generate the SAM deployment descriptor.
29+
I added a new Example project : `SAM`. It contains two Lambda functions, one invoked through HTTP API, and one invoked through SQS. It also defines shared resources such as SQS Queue and a DynamoDB Table. It provides a `Deploy.swift` example to describe the required HTTP API and SQS code and to allow `AWSLambdaDeploymentDescriptor` to generate the SAM deployment descriptor. The project also contains unit testing for the two Lambda functions.
3030

3131
### Result:
3232

@@ -74,7 +74,7 @@ struct HttpApiLambda: SimpleLambdaHandler {
7474

7575
2. I create a `Deploy.swift` file to describe the SAM deployment descriptor. Most of the deployment descriptor will be generated automatically from context, I just have to provide the specifics for my code. In this example, I want the Lambda function to be invoked from an HTTP REST API. I want the code to be invoked on `GET` HTTP method for the `/test` path. I also want to position the LOG_LEVEL environment variable to `debug`.
7676

77-
I add a new `Deploy.swift` file at the top of my project. Here is a simple deployment file. A more complex one is provided in the commit.
77+
I add the new `Deploy.swift` file at the top of my project. Here is a simple deployment file. A more complex one is provided in the `Examples/SAM` sample project.
7878

7979
```swift
8080
import AWSLambdaDeploymentDescriptor
@@ -107,34 +107,12 @@ swift package --disable-sandbox archive
107107
swift package --disable-sandbox deploy
108108
```
109109

110-
Similarly to the archiver plugin, the deployer plugin must escape the sandbox because the SAM CLI makes network calls to AWS API (IAM and CloudFormation) to validate and deploy the template.
110+
Similarly to the archiver plugin, the deployer plugin must escape the sandbox because the SAM CLI makes network calls to AWS API (IAM and CloudFormation) to validate and to deploy the template.
111111

112112
4. (optionally) Swift lambda function developer may also use SAM to test the code locally.
113113

114114
```bash
115-
sam local invoke -t sam.yaml -e test/apiv2.json HttpApiLambda
116-
Invoking Provided (provided.al2)
117-
Decompressing /Users/stormacq/Documents/amazon/code/lambda/swift/swift-aws-lambda-runtime/Examples/SAM/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/HttpApiLambda/HttpApiLambda.zip
118-
Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided.al2:rapid-1.67.0-arm64.
119-
120-
Mounting /private/var/folders/14/nwpsn4b504gfp02_mrbyd2jr0000gr/T/tmpc6ajvoxv as /var/task:ro,delegated inside runtime container
121-
START RequestId: 23cb7237-5c46-420a-b311-45ae9d4d19b7 Version: $LATEST
122-
2022-12-23T14:28:34+0000 info Lambda : [AWSLambdaRuntimeCore] lambda runtime starting with LambdaConfiguration
123-
General(logLevel: debug))
124-
Lifecycle(id: 157597332736, maxTimes: 0, stopSignal: TERM)
125-
RuntimeEngine(ip: 127.0.0.1, port: 9001, requestTimeout: nil
126-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleId=157597332736 [AWSLambdaRuntimeCore] initializing lambda
127-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] lambda invocation sequence starting
128-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] requesting work from lambda runtime engine using /2018-06-01/runtime/invocation/next
129-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] sending invocation to lambda handler
130-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [HttpApiLambda] HTTP API Message received
131-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] reporting results to lambda runtime engine using /2018-06-01/runtime/invocation/23cb7237-5c46-420a-b311-45ae9d4d19b7/response
132-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] lambda invocation sequence completed successfully
133-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=1 [AWSLambdaRuntimeCore] lambda invocation sequence starting
134-
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=1 [AWSLambdaRuntimeCore] requesting work from lambda runtime engine using /2018-06-01/runtime/invocation/next
135-
END RequestId: 23cb7237-5c46-420a-b311-45ae9d4d19b7
136-
REPORT RequestId: 23cb7237-5c46-420a-b311-45ae9d4d19b7 Init Duration: 0.44 ms Duration: 115.33 ms Billed Duration: 116 ms Memory Size: 128 MB Max Memory Used: 128 MB
137-
{"headers":{"content-type":"application\/json"},"body":"{\"isBase64Encoded\":false,\"headers\":{\"x-forwarded-for\":\"90.103.90.59\",\"sec-fetch-site\":\"none\",\"x-amzn-trace-id\":\"Root=1-63a29de7-371407804cbdf89323be4902\",\"content-length\":\"0\",\"host\":\"x6v980zzkh.execute-api.eu-central-1.amazonaws.com\",\"x-forwarded-port\":\"443\",\"accept\":\"text\\\/html,application\\\/xhtml+xml,application\\\/xml;q=0.9,image\\\/avif,image\\\/webp,*\\\/*;q=0.8\",\"sec-fetch-user\":\"?1\",\"user-agent\":\"Mozilla\\\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko\\\/20100101 Firefox\\\/108.0\",\"accept-language\":\"en-US,en;q=0.8,fr-FR;q=0.5,fr;q=0.3\",\"sec-fetch-dest\":\"document\",\"dnt\":\"1\",\"sec-fetch-mode\":\"navigate\",\"x-forwarded-proto\":\"https\",\"accept-encoding\":\"gzip, deflate, br\",\"upgrade-insecure-requests\":\"1\"},\"version\":\"2.0\",\"queryStringParameters\":{\"arg1\":\"value1\",\"arg2\":\"value2\"},\"routeKey\":\"$default\",\"requestContext\":{\"domainPrefix\":\"x6v980zzkh\",\"stage\":\"$default\",\"timeEpoch\":1671601639995,\"apiId\":\"x6v980zzkh\",\"http\":{\"protocol\":\"HTTP\\\/1.1\",\"sourceIp\":\"90.103.90.59\",\"method\":\"GET\",\"userAgent\":\"Mozilla\\\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko\\\/20100101 Firefox\\\/108.0\",\"path\":\"\\\/test\"},\"time\":\"21\\\/Dec\\\/2022:05:47:19 +0000\",\"domainName\":\"x6v980zzkh.execute-api.eu-central-1.amazonaws.com\",\"requestId\":\"de2cRil5liAEM5Q=\",\"accountId\":\"486652066693\"},\"rawQueryString\":\"arg1=value1&arg2=value2\",\"rawPath\":\"\\\/test\"}","statusCode":202}%
115+
sam local invoke -t sam.json -e Tests/LambdaTests/data/apiv2.json HttpApiLambda
138116
```
139117

140118
### Command Line Options

0 commit comments

Comments
 (0)