Cognito user pool authorizer With Serverless Framework

nusgajy picture nusgajy · Jan 15, 2017 · Viewed 11.6k times · Source

I need to authorize my API end point using aws cognito userpool. I can do it manually, but I need to automate the authorization part with the serverless framework.

Does the Serverless framework have support for aws cognito?

If so, how do we setup an aws-userpool with serverless?

Answer

Niroshan Ranapathi picture Niroshan Ranapathi · Jan 15, 2017

Yes . Serverless (v1.5) support to Cognito user pool authorizer.

If you use previous version of serverless you have to update v1.5 or later.

For the user-pool authorization of api end point you have to specify pool arn.

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get
          integration: lambda
          authorizer:
            name: authorizer
            arn: arn:aws:cognito-idp:us-east-1:123456789:userpool/us-east-1_XXXXXX

More details read this article.