Reputation: 1871
I am trying to create a cognito user pool ID and the app client using Serverless.yml file
I am referring this link -
https://serverless-stack.com/chapters/configure-cognito-user-pool-in-serverless.html
I want to use this Cognito user pool id in my lambda function code.
Is there any way I can get this User Pool ID and app client ID in my lambda code?
Is there any way serverless can create some environment variables, etc. which can hold the values for user pool ID and the App client ID?
Upvotes: 5
Views: 1859
Reputation: 7417
You can do the following:
myFunction:
handler: '...'
environment:
USER_POOL_ID: # The name of the env var in your lambda
Ref: CognitoUserPool # The name of your resource in Resources section
APP_CLIENT_ID:
Ref: CognitoUserPoolClient
It works because serverless uses CloudFormation under the hood.
See also Return Values of AWS::Cognito::UserPool and Ref.
Upvotes: 8