是否将会话令牌存储在AWS Lambda函数中? [英] Storing the session token in AWS Lambda function?

查看:98
本文介绍了是否将会话令牌存储在AWS Lambda函数中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AWS Lambda函数,需要与外部REST API对话.外部API的每个请求都需要一个会话令牌.

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.

我使用客户端ID和密码生成会话令牌,然后将会话令牌用于对外部REST API的进一步请求.

I generate session token using client id and secret and then i use the session token with further requests to the external REST API.

我目前正在将会话令牌存储在mongodb中(以在lambda重新启动期间持久存储数据),并在每次需要时检索它.我认为这不是最好的方法.最佳/推荐的方法是什么?

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 ?

推荐答案

您正在使用的这种方法目前是合理的,因为它对保持Lamda函数无状态,同时在该函数之外存储会话信息很重要.

The approach you are using currently reasonable since its important to keep Lamda functions stateless while storing session information outside the function.

无需配置MongoDB集群,您可以使用Amazon DynamoDB存储会话数据并针对每个请求进行检索.

Without provisioning a MongoDB cluster, you can use Amazon DynamoDB to store the session data and retrieve for each request.

注意:如果您打算进一步提高性能,则可以考虑使用内存数据库或DAX(如果使用DynamoDB).

Note: If you are planning to do further performance improvements, you can consider using an in-memory database or DAX (If you use DynamoDB).

这篇关于是否将会话令牌存储在AWS Lambda函数中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆