Replies: 5 comments 1 reply
-
You can call a lambda function directly using the invoke function from the lambda library in Soto. But you are probably better to setup an APIGateway so you can invoke the lambda function with an HTTP client. There are examples out there to do this. @sebsto do you know where the most up to date guides or examples are for this? |
Beta Was this translation helpful? Give feedback.
-
Hello @ToddHoff In the context of an iOS app, this is not the right way to do, because you don't want to expose AWS credentials in your app. The most common way to expose a Lambda function to another application is through the API Gateway. You deploy your Lambda function together with an API that will offer an HTTP (TLS) endpoint, take care of the decoding of the parameters (HTTP headers, query params, request params) and send them as a JSON payload to your Lambda function. The easiest way to deploy such a group of Lambda function + API Gateway is to use SAM. If you write your Lambda functions in Swift, I wrote a tutorial showing you how to get started and use SAM to deploy and test your function end to end. You can also use the VSCode Lambda SAM plugin to get started with a project with just a few clicks These tutorial typically do not address the authentication part. The best practice here is to protect the API Gateway with a JWT token based authentication and use the authentication token your app received when the user authenticated. I hope these resources will help you to get started. Let us know if anything is unclear and give us feedback to make them even more useful. |
Beta Was this translation helpful? Give feedback.
-
Oh, I should have added, check the Serverless land pattern collection. This is an incredible collection of 830+ serverless patterns, many of them include AWS Lambda, API Gateway and SAM. |
Beta Was this translation helpful? Give feedback.
-
Thanks. I got the basics from the lambda test harness, which worked great. I appreciate all the hard work that went into the library. Amazing. I've used the JWT token approach on the web with Cognito. Authentication is by far the hardest part of this whole process, so code examples would be most helpful. For this, I think using keys for a user with minimum permissions should work well enough. |
Beta Was this translation helpful? Give feedback.
-
I didn't want to mention / push for Cognito in my first reponse to not look like too salesly :-) Amplify allows you to provision these backend resources in a very very easy way, with most of the configuration done for you, and it provides a Swift native client side library to easily access the cloud resources. I contributed to the Amplify Swift getting started guide (be sure to select Gen - read it, give it a try and give us feedback. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'd like to call a Lambda function from an iOS app. I've been unable to find any examples of how to do this. Can someone please point me to some example code?
thanks
Beta Was this translation helpful? Give feedback.
All reactions