From c936a7ea432bb64f47adada90c18a3a41c07e28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Tue, 12 Nov 2024 22:15:03 +0100 Subject: [PATCH] add an lambda event example in the readme file --- readme.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 23247d5d..b5805d80 100644 --- a/readme.md +++ b/readme.md @@ -179,7 +179,7 @@ let runtime = LambdaRuntime { try await runtime.run() ``` -You can learn how to deploy and invoke this function in [the example README file](Examples/HelloJSON/README.md). +You can learn how to deploy and invoke this function in [the Hello JSON example README file](Examples/HelloJSON/README.md). ### Lambda Streaming Response @@ -216,7 +216,30 @@ let runtime = LambdaRuntime.init(handler: SendNumbersWithPause()) try await runtime.run() ``` -You can learn how to deploy and invoke this function in [the example README file](Examples/Streaming/README.md). +You can learn how to deploy and invoke this function in [the streaming example README file](Examples/Streaming/README.md). + +### Integration with AWS Services + + Most Lambda functions are triggered by events originating in other AWS services such as `Amazon SNS`, `Amazon SQS` or `AWS APIGateway`. + + The [Swift AWS Lambda Events](http://github.com/swift-server/swift-aws-lambda-events) package includes an `AWSLambdaEvents` module that provides implementations for most common AWS event types further simplifying writing Lambda functions. + + Here is an example Lambda function invoked when the AWS APIGateway receives an HTTP request. + + ```swift +import AWSLambdaEvents +import AWSLambdaRuntime + +let runtime = LambdaRuntime { + (event: APIGatewayV2Request, context: LambdaContext) -> APIGatewayV2Response in + + APIGatewayV2Response(statusCode: .ok, body: "Hello World!") +} + +try await runtime.run() +``` + + You can learn how to deploy and invoke this function in [the API Gateway example README file](Examples/APIGateway/README.md). ### Integration with Swift Service LifeCycle @@ -269,7 +292,7 @@ let runtime = LambdaRuntime.init(handler: adapter) try await runtime.run() ``` -You can learn how to deploy and invoke this function in [the example README file](Examples/BackgroundTasks/README.md). +You can learn how to deploy and invoke this function in [the background tasks example README file](Examples/BackgroundTasks/README.md). ## Deploying your Swift Lambda functions