@Manuel Villafañe
If (1) your roles are static, that is you're not working with user-defined roles, (2) if you don't have tons of them, and (3) you're talking about resource authorization, the resource being what the API gateway has knowledge of like the endpoint + method, then you can also inject your roles as claims using the
pre-token generation trigger from Cognito. The lambda attached to that trigger will look up your DB and shape the returned JWT accordingly. Then you simply use a JWT authorizer with the right
authorizationScopes.
Now,
If (1) your roles are user-defined, then you'll have to use custom authorizers to fetch, inject, and authorize on the fly. You may, of course, have one single custom authorizer for your whole system, if you have a centralized role management sub-system.
If (2) you have tons of roles, then by injecting them into your JWT tokens, you might be clogging all your API requests.
If (3) you want to perform action or data access control, then you'll (also) need to perform fine-grained authorization in your lambda handler. You, of course, have one single custom "middleware" for authorization and have something like :
*request > request validation > action authorization > data authorization > * model run * > data authorization > response validation > response*
Finally, if may also want to embed some data-level access control into your model. For instance, for DynamoDB you may attach a dynamic permissions to your request to limit the access to attributes or entries :
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/specifying-conditions.html