Examples of authorisation in serverless solutions alongside both machine to machine and user authentication, using Cognito, Lambda, Middy & Lambda Layers; with examples and code repo written in the AWS CDK and TypeScript.
The article can be found here: https://leejamesgilmore.medium.com/serverless-authorisation-e5bd9288f0ff
To deploy the solution please look at the steps in the article linked above.
** The information and code provided are my own and I accept no responsibility on the use of the information. **