Search code examples
typescriptaws-api-gatewayamazon-cognitoaws-cdk

AWS Cognito + API Gateway + Calling Cognito Token Endpoint


Noob question here (beginner in AWS services). I wanted to create an API Gateway between the AWS Cognito and the one that's going to call the Cognito Token Endpoint. Is there a way how to implement it using a CDK? It is used to cache the Access Token.


Solution

  • Found a way to use an API Gateway between Cognito and the caller. It is using an HTTP Proxy.

    Here's the guide: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-http.html

    And for caching the tokens, this might help: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-caching-tokens.html

    The caching is enabled only for the GET method by default. If you are trying to use other types of HTTP Methods, might try to override the stage settings for it.

    Here's the guide: https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/api-gateway-caching.html#override-api-gateway-stage-cache-for-method-cache