Progress
Life has been busy. I've also been putting some time into this project, but not a lot. I don't have a lot of details, but here's what I've been up to, mostly around trying to get the Vue UI to get data from the dynamo db (vue -> api gateway -> lambda w/ cognito authentication). The things I struggled the most with:
CORS. What a pain. Interaction between APIGateway and lambda function is confusing. Apparently the behavior is different between HTTP and REST apis, and sometimes honored and sometimes not (there were many times where I thought I cracked the code, to then have a refresh break it again). I'm sure it is just my ignorance, but this was very frustrating. I spent (wasted) so much time on this but have something that sorta functions right now. I understand CORS (or really SOPs) are a browser-enforced thing but it was annoying to not be able to use tools like postman to figure out what is going on (wrong).
Authentication. I'm using Cognito as my authentication service. I thought it would be easy to hook that up to the API Gateway/lambda function under the Amplify tool/environment. It was not. After trying hundreds of wrong combinations I finally stumbled upon the fact that I had to create a Cognito Pool Authorizer.
...then specify that as the authorizer for the endpoints. I spent so much time trying to use the default IAM (and incorrect) option.
Now that I can see the end-to-end flow better, I want to restructure my Cognito configuration and dynamo db data. This is why I like to work from both ends and work to the middle on things that I don't really understand. It would be a waste of time and effort to come up with a "perfect" solution on one end only to realize that there is a huge impedance mismatch with the other end and either end up building wonky converters or rewriting that "perfect" solution.
Cognito changes: Include a name (not just an email), as well my own User Id. The sub field will give me a specify user id, but I've been trained/burned to use my own IDs... maybe i'll just live with it since it is an uuid. It looks like I will have to create a new Pool to make any configuration changes. Annoying, but OK -- I'd like to rename it to be more easy to identify anyway.
Dynamo db changes: figure out the right partition and sort keys to use. My query right now has to use a scan (not query) because of how the data is structured and how I set it up initially, which is not as performant as it could be (who cares when I have 1 doc in there right now), but as I understand it, it could become expensive too as the number of documents increases (RCUs).
I'm not quite ready to have a dev & prod environment yet, but I'm getting close. Well, phrased a different way... I want multiple environments so that I can start using the building blocks I have so far in "prod" - however clumsy it might be -- without fear of future development breaking something. But I want to do a lot of rework/refactoring before crossing that bridge.
I also want to explore Pinia for state management in the app, and to start structuring the UI code a bit better. Right now I feel like it is all kind of a jumble of junk.
Comments