You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Plugins/AWSLambdaDeployer/README.md
+5-27Lines changed: 5 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,11 +22,11 @@ SAM is already broadly adopted, well maintained and documented. It does the job.
22
22
23
23
I added two targets to `Package.swift` :
24
24
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.
26
26
27
27
-`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.
28
28
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.
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`.
76
76
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.
78
78
79
79
```swift
80
80
importAWSLambdaDeploymentDescriptor
@@ -107,34 +107,12 @@ swift package --disable-sandbox archive
107
107
swift package --disable-sandbox deploy
108
108
```
109
109
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.
111
111
112
112
4. (optionally) Swift lambda function developer may also use SAM to test the code locally.
113
113
114
114
```bash
115
-
sam local invoke -t sam.yaml -e test/apiv2.json HttpApiLambda
2022-12-23T14:28:34+0000 debug Lambda : lifecycleIteration=0 [AWSLambdaRuntimeCore] requesting work from lambda runtime engine using /2018-06-01/runtime/invocation/next
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
0 commit comments