I am looking for some general architectural guidance about designing good cloud apps, primarily using AWS. For the sake of argument, lets say it’s a single page app, written in JS, hitting a couple of services like S3 and maybe some Lambda functions that read/write to a DynamoDB.
Option 1 – Make calls directly using AWS SDK So, this seems to be how the documentation is written. Your app would auth the user using Cognito, exchange for the tokens, then connect to the services directly.
Benefits here: Code is in the UI, so less moving parts. Cognito seems geared towards this type of dev…otherwise your server parts would have to cache the tokens or you’d somehow have to pass them around from the client. It also seems like less cost since you wouldn’t be paying for an “intermediary” service to bounce calls off of.
Cons: Well, your code is all in the UI, making your UI bloated. It feels like too much business logic would be in the client, which feels wrong.
Option 2 – Intermediary services Basically you would write some service, be it a Lambda function or an EC2 microservice or the like, to “bounce” the calls off of.
Benefits here: Well, you would have some additional level of control. Also, these intermediaries could house most, if not all, of the business logic.
Cons: Well, the biggest one is cost as you would now have to host a bunch of extra “things” to service your calls. Also, for the most part, it would seem like most of your intermediary services would be pass-through, so where is the benefit?