title: AWS Cognito to authenticate App users and retrieve settings from MySQL database
body: <p>I am doing some research for a mobile app I want to develop, and was wondering whether I could get feedback on the following architecture. Within my future app users should be able to authenticate and register themselves via the mobile app and retrieve and use their settings after a successful authentication.</p>
  
  <p>What I am looking for is an architecture in which user accounts are managed by AWS Cognito, but all application related information is stored in a MySQL database hosted somewhere else.</p>
  
  <p>Why host the database outside of AWS? Because of high costs / vendor lock-in / for the sake of learning about architecture rather than going all-in on AWS or Azure</p>
  
  <p>Why not build the identity management myself? Because in the end I want to focus on the App and don't spent a lot of energy on something that AWS can already provide me with (yeah I know, not quite in line with my last argument above, but otherwise all my time goes into database AND IAM)</p>
  
  <p>One of my assumptions in this design (please correct me if I am wrong) is that it is only possible to retrieve data from a MySQL database with 'fixed credentials'. Therefore, I don't want the app (the user's device) to make these queries (but do this on the server instead) as the credentials to the database would otherwise be stored on the device. </p>
  
  <p>Also, to make it (nearly) impossible for users to run queries on the database with a fake identity, I want the server to retrieve the User ID from AWS Cognito (rather than using the ID token from the device) and use this in the SQL query. This, should protect the service from a fake user ID injection from the device/user.</p>
  
  <p>Are there functionalities I have missed in any of these components that could make my design less complicated or which could improve the flow?</p>
  
  <p><a href="https://i.stack.imgur.com/SrTGH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SrTGH.png" alt="architecture design"></a></p>