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年前1314ビュー
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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ