Modifying/Updating the Cognito User Pool
It wasn't as easy as I hoped, but still got it done in about an hour.
You cannot MODIFY the User pool to have additional sign-up required fields. I knew this going in.
I manually configured a new Cognito user pool via aws console
required a nickname to be provided
added optional custom field for userId
Again, trial-and-error, but the thing that worked was using the commands:
amplify remove auth (was scary)
amplify import auth (much easier than I thought, only needed to provide the pool id and everything else was automatic)
amplify push
Used my UI to create a new user
Worked great, although I need to figure out how to hook in to provide the custom:userId attribute during (or right-after) sign-up. This new user has a null value for that field right now.
Tried to query data
failed; sort-of expected that.
Needed to change the Cognito User Pool in use by the API Gateway Authorizer. I changed this several times (+ deploying the api) and it just wouldn't work -- kept getting 401 responses. Until one time it did, and has been working since then.
Even after that, querying data in the lambda didn't work because the user Sub id was different (of course) -- simply modified the data and that started working (note: changing the data structure / partition key is one of the next steps, but was not tackled as part of swapping out the Cognito User Pool)
Deleted the old Cognito User Pool (I hate clutter -- leads to too much reading, potential mistakes, more aws $, etc).
Tidied up the UI a bit (where I was displaying a user name from the data before, I changed it to display the nickname from the Cognito account).
About 8 commits/pushes in git (small incremental changes...)
That's enough for today.
Next Step thoughts:
How to generate my own userId and store on Cognito record during sign-up
Give the ability to change user name to the user (update cognito record).
Restructure Dynamo DB
Pinia state management
Quick Follow-ups:
✔️Generating my own user Id was fairly easy. Key bits:
✔️update user name in cognito. Was pretty easy. Basically Auth.updateUserAttributes.
✔️Restructure dynamo db QUERY was pretty easy, as well as querying based on my custom user id. RCU for each query went from 2 to 0.5. $$$. I still need to look at my data access patterns and create a better overall dynamo db structure
✔️Implemented Pinia but need to improve access patterns.
Comments