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
posta 5 anni fa1397 visualizzazioni
2 Risposte
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.

con risposta 5 anni fa
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
con risposta 5 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande