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 年前檢視次數 1396 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南