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년 전1330회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠