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
{{ message }}
This repository was archived by the owner on Mar 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+85
Original file line number
Diff line number
Diff line change
@@ -358,6 +358,91 @@ make upload_lambda_layer
358
358
make update_lambda
359
359
```
360
360
361
+
# Local development
362
+
363
+
Development and test can be simplified by using a sandboxed local environment replicating of the AWS Lambda by using the [lambci/lambda:provided](https://github.com/lambci/docker-lambda) Docker image.
364
+
365
+
The local sandboxed Lambda can be launched just to test the Lambda once or more than once.
366
+
367
+
To run the sandboxed Lambda environment it's required to share the files contained in the layer, the boostrap and the files required by the build with the ```lambci/lambda:provided``` Docker image.
-```$LOCAL_LAMBDA_PATH```: the path containing the build
378
+
-```$SHARED_LIBS_FOLDER```: the path containing the extracted swift runtime libraries
379
+
-```$LAMBDA_HANDLER```: the lambda handler
380
+
-```$LOCAL_LAMBDA_EVENT```: the event json string
381
+
382
+
383
+
To run the Lambda locally follow the [Lambda development workflow](https://github.com/swift-sprinter/aws-lambda-swift-sprinter#lambda-development-workflow) to the step 4:
384
+
385
+
1) Requirements: Clone the repository and install Docker
386
+
2) Prepare a custom docker image: ```make docker_build```
387
+
3) Build the lambda layer: ```make package_layer```
388
+
4) Write the lambda code
389
+
390
+
To simplify the local execution swift-sprinter added some useful commands:
391
+
392
+
## Lambda Local
393
+
394
+
### Build lambda locally
395
+
396
+
Build the lambda and copy the artefacts under ```$LOCAL_LAMBDA_PATH```
397
+
398
+
```make build_lambda_local```
399
+
400
+
### Invoke lambda local once
401
+
402
+
Invoke the Lambda locally once with Docker and LambCI on port ```9001```
403
+
404
+
```make invoke_lambda_local_once```
405
+
406
+
### Start lamba local environment
407
+
408
+
Start the local environment with Docker and LambCI on port ```9001```
409
+
410
+
```make start_lambda_local_env```
411
+
412
+
Keep it running and open a new terminal window to invoke the lambda.
413
+
414
+
Use ```ctrl^C``` to stop it.
415
+
416
+
### Invoke the lambda locally
417
+
418
+
Invoke the lambda locally using the endpoint ```http://localhost:9001``` with the aws cli.
419
+
420
+
```make invoke_lambda_local```
421
+
422
+
## Use of Docker Compose
423
+
424
+
To test lambda locally with more complex environment it's possible to use Docker Compose.
425
+
426
+
All the examples in the repository have their own ```docker-compose.yml``` file to run the example locally listening on the port ```9001```.
427
+
428
+
### Start the Docker Compose
429
+
430
+
Start the docker-compose test environment
431
+
432
+
```make start_docker_compose_env```
433
+
434
+
### Invoke the lambda locally
435
+
436
+
Invoke the lambda locally using the endpoint ```http://localhost:9001``` with the aws cli.
0 commit comments