amazon-web-services - Accessing Cognito user attributes from Appsync
问题描述
Imagine that you have a simple AWS stack with Appsync, Aurora RDS and Cognito.
Obviously, Cognito manages the users registration process, where each user has a few attributes, let's say email
, first_name
, and last_name
.
Also there is a table called users
in Aurora RDS, which, among other columns, has the cognito_id
column where it stores the reference to the Cognito users' IDs.
The last thing is AppSync GraphQL query that would list all the available users with fields that should come both from the users
RDS table and Cognito attributes. And that's where the question arises.
If it was needed to only fetch attributes from the users
table, the problem would be solved with some small and tidy SQL query that could be put into the AppSync VTL request template. But since it's also required to get the attributes from the Cognito users pool, things get complicated.
How could something like that be done in an efficient and scalable way? Or is it a bad design and there's a better way to do it?
解决方案
我的经验告诉我在使用 Cognito 时不要有表 Users。我们可以在 Cognito 属性中保存的所有数据。但也许它需要你。但是,您可以将 Lambda 函数用作 AppSync 数据源。并在 Lambda 函数中从 Cognito 获取数据。
推荐阅读
- c# - json序列化程序将日期时间转换为任何字符串
- javascript - ASP NET Core (.NET 5.0) 中的脚本部分和缩小文件
- javascript - 确定 Eclipse 是否显示使用 -webkit-line-clamp 截断的文本
- javascript - 即使安装在 node_modules 中,节点也找不到模块
- r - RStudio 每月时间序列数据图问题
- sql - 选择所有降落在马略卡岛帕尔马或巴塞罗那但不是同时降落的所有乘客
- influxdb - influx V2.x:按通量分组
- python - 如何将 python 文件导入模块的多个文件,而它们不使用相同的变量?
- python - 根据使用python的第1列中的内容将csv拆分为多个csv
- node.js - 第一次尝试设置 Angular 应用程序