I have an architecture design where I am using Cognito for user management (email, phone_number are the only attributes) and then I am using DynamoDB to also sync users so that I can make user of AppSync to query and fetch some user information.
I need some way of syncing both the DynamoDB users with Cognito users. At the moment, I have a user postConfirmation lambda trigger to run inserts into DynamoDB on new user confirmation for all of the above information BUT:
- how do I manage a user updating their email / phone: If I use Cognito directly for this and they then have to confirm their new phone number / email there doesn't seem to be another Lambda trigger I can add here to sync this new data with DynamoDB.
- If I user DynamoDB via Appsync to update user email and phone and then kick that out through a DynamoDB stream to a lambda function to update this info in Cognito, the user has not yet confirmed these details and thus the information may be invalid.
What is the ideal architecture for keeping Cognito and DynamoDB in sync?