# How to get Cognito User Pool ID and the App client Id in Lambda

**URL:** <https://forum.serverless.com/t/how-to-get-cognito-user-pool-id-and-the-app-client-id-in-lambda/8334>\
**Category:** Serverless Framework\
**Tags:** aws, cloudformation\
**Created:** [May 21, 2019, 12:46pm UTC](https://forum.serverless.com/t/how-to-get-cognito-user-pool-id-and-the-app-client-id-in-lambda/8334 "2019-05-21T12:46:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![moro](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/moro/32/4303_2.png) [@moro](https://forum.serverless.com/u/moro)\
**Post date:** [May 21, 2019, 7:31pm UTC](https://forum.serverless.com/t/how-to-get-cognito-user-pool-id-and-the-app-client-id-in-lambda/8334/2 "2019-05-21T19:31:28Z")

</div>

Hi, you can do it in this way

```auto
resources:
....
  Outputs:
    UserPoolId:
      Value:
        Ref: CognitoUserPool
      Export:
        Name: ${self:provider.stage}-UserPoolId

    UserPoolClientId:
      Value:
        Ref: CognitoUserPoolClient
      Export:
        Name: ${self:provider.stage}-UserPoolClientId

```

```auto
functions:
   your-function:
     ....
     environment:
       USER_POOL_ID: !ImportValue ${self:provider.stage}-UserPoolId
       USER_POOL_CLIENT_ID: !ImportValue ${self:provider.stage}-UserPoolClientId

```

your-function.js

```auto
   const { USER_POOL_ID, USER_POOL_CLIENT_ID } = process.env;
   ...

```

p.s.  
If your functions + resources are in the same stack - you can just use `USER_POOL_ID: !Ref CognitoUserPool` and `USER_POOL_CLIENT_ID: !Ref CognitoUserPoolClient`

---

_[View the full topic](https://forum.serverless.com/t/how-to-get-cognito-user-pool-id-and-the-app-client-id-in-lambda/8334)._
