Can I host webhook for my lex bot on my own server instead of AWS Lambda? - aws-lex

Seems like AWS Lex supports using AWS Lambda for hosting my application logic. Can I provide my own custom webhook instead of using AWS Lambda?
I would like to host my own server and use it to handle the webhook requests.

This is not currently possible, Lex can only integrate with Lambda functions to run some back-end logic.
If you have to run code off your own server, you could make a request to the server from the Lambda function to fetch the response and then return it back to Lex. However, if you want to do this to minimize Lambda associated costs, this wouldn't help.

Related

Invoke directly lambda vs SNS trigger lambda

In case of a event driven serverless stack with a HTTPS call in a Rest API and the trigger of another lambda to answer in a Websocket API, what is the best solution between SNS lambda trigger or aws sdk invoke in a asynchronus event architecture?
I can clearly see why choosing aws sdk invoke:
No need to implement another service, easier
Invoke is made by direct invoke from the code of lambda (fast, no duplicates, ...)
So I can't see the usefullness of adding SNS in between insted of a lot more configuration.
Just for more information, the second lambda is like a microservice to answer on websocket.

AWS lambda event reprocess request

Sometimes my backend database goes offline and the AWS lambda execution which requires this backend fails. Can I ask AWS to reprocess the same event in a later time hoping that the backend goes online by that time? I'm using node.js for my lambda code.
Yes, you can use AWS lambda's DLQ service. It sends all failed executions to SNS/SQS, you can review them and reprocess them from their.
Link to doc https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html (scroll to AWS Lambda function dead-letter queues)

Creating SQS Queues with lambda

I'm working on a collaborative document project (basically a clone of google docs), where client-programs post their actions to an API on amazon's API gateway, then receive messages of other client's actions via an SQS queue. The API calls trigger Node.js lambda functions that create a message, publish it to an SNS which then notifies each client's SQS.
My current hurdle is in dynamically creating/destroying SQS queues for these clients as they join/leave a document, however my googlefu is weak and I have failed to find anything that could help me. I'd like to keep the queue management server-side and ideally in lambda, but if that's impossible I will accept other solutions.
You can simply use the AWS SDK for Javascript in your AWS Lambda function (it's already pre-installed there) and use it to manage any kind of AWS resources, e.g. the requested creation and deletion of SQS queues.

AmazonWebService - Should i use AWS API Gateway or AWS SDK

I'm trying to call a lambda function from NodeJS. After research i know 2 ways to do it:
Assign Lambda function into AWS API Gateway and call that API.
Call Lambda function through AWS SDK
What are pros and cons of API Gateway and AWS SDK ? And when to use each way above?
It depends. API Gateway is mostly used to give temporary access to Lambda functions in environments that are not secure (i.e. browsers, desktop apps, NOT servers).
If your environment is secure, as in it runs on an EC2 instance with an IAM role, or another server with secure stored credentials, then feel free to use the SDK and call the Lambda function correctly.
If you need to expose your Lambda function to the entire internet, or to authorised users on the web, or to any user that has the potential to grab the access key and secret during transit, then you will want to stick API Gateway in front.
With API Gateway you can secure your Lambda functions with API keys, or through other authorisers such as Amazon Cognito so that users need to sign in before they can use the API endpoint. This way they only gain temporary credentials, rather than permanent ones that shouldn't be available to anyone.
I disagree with _DF about the security concern on invoking lambda directly through client. Over the 4 years I implementing Client + AWS SDK on my serverless approach. Direct hit to all microservices we have such as Lambda, DynamoDB, S3, SQS, etc.
To work with this approach, we have to strong understand about IAM Role Policy including its statements concept, Authentication Token, AWS Credential, and Token - Credential exchange.
For me, using SDK is better to implement serverless rather than API Gateway. Why I prefer to implementing SDK instead of API on my serverless infra?
API Gateway is Costly
Network hop-less
In fact, SDK is commonly contain an API to communicate with other applications Class base and simple call such as dynamodb.put(params).promise(), lambda.invoke(params).promise(), s3.putObject(params).promise(), etc. We can see a sample API call like fetch(URL).promise(), the term is not really different
API is more complex and some case can't or shouldn't be handled with
SDK is not scalable? No, I dont think so. Because it's class base, it's so scalable.
Slimming the infra and code writing, i.e to work with s3 no need deploy API+Lambda
Speed up the process, i.e storing data to dynamodb no need business logic through API+lambda
Easy maintaining, we only maintain our client code
Role Policy is more scalable; etc

How Can I Make A Public API Route For An AWS Lambda Function?

Does AWS Lambda provide a way to make a public route/endpoint for my Lambda functions?
Or do I have to build an entire app to handle routing and invoking Lambda functions?
Yes they do!
As of July 9th they have an api endpoint section that allows you to invoke your lambda function from anywhere!
http://aws.amazon.com/about-aws/whats-new/2015/07/invoke-aws-lambda-functions-over-https/.
You can also use API gateway with lambda to design and test your api.

Resources