# How to access Cognito User Pool Arn as a function authorizer?

**URL:** <https://forum.serverless.com/t/how-to-access-cognito-user-pool-arn-as-a-function-authorizer/9630>\
**Category:** Serverless Framework\
**Tags:** aws, api-gateway\
**Created:** [October 16, 2019, 1:31am UTC](https://forum.serverless.com/t/how-to-access-cognito-user-pool-arn-as-a-function-authorizer/9630 "2019-10-16T01:31:39Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![luckyvalentine](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@luckyvalentine](https://forum.serverless.com/u/luckyvalentine)\
**Post date:** [October 16, 2019, 8:40pm UTC](https://forum.serverless.com/t/how-to-access-cognito-user-pool-arn-as-a-function-authorizer/9630/5 "2019-10-16T20:40:11Z")

</div>

SOLVED.

I was able to reference an explicitly declared authorizer. In my cognito-user-pool.yml file I added the MyApiGatewayAuthorizer section, ending up with

```
CognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: company-${self:custom.stage}-user-pool

      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email

  MyApiGatewayAuthorizer: 
    Type: AWS::ApiGateway::Authorizer
    Properties: 
      AuthorizerResultTtlInSeconds: 10
      IdentitySource: method.request.header.Authorization
      Name: MyCognitoAuthorizer
      RestApiId: 
        Ref: ApiGatewayRestApi
      Type: COGNITO_USER_POOLS
      ProviderARNs: 
        - {"Fn::Join": ["", ["arn:aws:cognito-idp:", {Ref: "AWS::Region"}, ":", {Ref: "AWS::AccountId"}, ":userpool/", Ref: CognitoUserPool]]}

```

and in my function event definition, I specified the authorizer as such:

```
events:
  - http:
      path: target
      method: get
      cors: true
      authorizer:
        type: COGNITO_USER_POOLS
        authorizerId: { Ref: MyApiGatewayAuthorizer }

```

This worked for me. I hope it can help someone else!

---

_[View the full topic](https://forum.serverless.com/t/how-to-access-cognito-user-pool-arn-as-a-function-authorizer/9630)._
