Reputation: 61
I have a AWS Lambda function which need to talk to an external REST API. The external API needs a session token with every request.
I generate session token using client id and secret and then i use the session token with further requests to the external REST API.
I am currently storing the session token in mongodb (to persist data during lambda restarts) and retrieving it every time i need it. I think this is not the best way. what is the best / recommended way ?
Upvotes: 0
Views: 1958
Reputation: 19748
The approach you are using currently reasonable since its important to keep Lamda functions stateless while storing session information outside the function.
Without provisioning a MongoDB cluster, you can use Amazon DynamoDB to store the session data and retrieve for each request.
Note: If you are planning to do further performance improvements, you can consider using an in-memory database or DAX (If you use DynamoDB).
Upvotes: 3