Can I create relationship from User pool to table in DynamoDB?

0

Hi everyone,
I am newbie in AWS, I just wonder that can I create relationship from Cognito User pool to table in DynamoDB and what is the best practice to resolve my problem?

Here is my scenario:
_ I have a table named "Vehicles" and this table will only store UserID from Cognito User pool.
_ When I assign one Vehicle to User (from list Users of Cognito User pool), I will store UserID to this table.

My concern is: How can I retrieve User's information like family_name, given_name, etc... to display to UI when I get a list of Vehicles.

My current solution is: I created a table User to store all User info after user sign up or created. Then create relationship with Vehicles table and other table to handle business logic. But, when User update email, phone, or groups in User pool, I have to update to User table.

Could you guys give me some instruction?
Thank you!

ThanhD
已提问 5 年前1403 查看次数
2 回答
0

What I do is simply fetch the data from Cognito when needed.

So in your case, first fetch the Vehicle in DynamoDB, then fetch the user data, e.g. using adminGetUser (though that for some obscure reason does not support user id/sub, only username and alias, so listUsers with a filter for "sub" might be better).

I was about to suggest that you could use Lambda triggers if you really needed to store the attributes in DDB, but it seems there is no Lambda trigger for attribute updates, which is quite odd, but I guess you could get around that by only letting users update attributes through your backend, which could then do the DDB update as well.

已回答 5 年前
0

Thank you very much for your reply!
Yeah, I just add a Lambda trigger to save User info into DDB after they confirm signup. Then everything will be handled on backend and DDB.

ThanhD
已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则