question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refer to existing Cognito User Pool with ARN instead of pool name

See original GitHub issue

Use case description

When using an existing Cognito User Pool and adding trigger for lambda to this user pool, the existing way to do it is to :

  • define the lambda trigger in serverless.yml, thus creating the corresponding User Pool with given name :
customMessage:
    handler: customMessage.handler
    events:
      - cognitoUserPool:
          pool: MyUserPool
          trigger: CustomMessage
  • use the auto-generated resource name - CognitoUserPoolMyUserPool - to incrementally configure the user pool in native cloudformation files :
resources:
  Resources:
    CognitoUserPoolMyUserPool:
      Type: AWS::Cognito::UserPool

When using an existing pool, the only way to refer to it is using its name

functions:
  users:
    handler: users.handler
    events:
      - cognitoUserPool:
          pool: legacy-user-pool
          trigger: CustomMessage
          existing: true

However, if you did not specify any name for your user pool (this param is optional), you need to manually retrieve generated name from cognito and paste it in your serverless.yml. (there is no way from cloudformation to retrieve a generated user pool name, only logicalId, Arn, ProviderName and ProviderUrl -> https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html#aws-resource-cognito-userpool-return-values).

Proposed solution

Accept Arn of existing user pool as trigger for lambda :

functions:
  users:
    handler: users.handler
    events:
      - cognitoUserPool:
          poolArn: !Ref MyUserPool
          trigger: CustomMessage

Would be happy to dev this feature if accepted 😃

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tommedemacommented, Aug 2, 2022

any update on this?

2reactions
medikoocommented, Aug 18, 2020

@medikoo, would you be OK to have both solutions implemented,

@fredericbarthelet definitely! Still let’s cover that with two distinct PR’s

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify Cognito User Pool authorizer by ARN not name?
I am looking for an option to pass user pool ARN instead of name to preSignUp trigger to reference existing user pool. Is...
Read more >
Amazon Cognito user pools
A user pool is a user directory in Amazon Cognito. With a user pool, your users can sign in to your web or...
Read more >
describe-user-pool — AWS CLI 2.9.6 Command Reference
The user pool ID for the user pool you want to describe. ... The Amazon Resource Name (ARN) of the Lambda function that...
Read more >
Amazon Cognito Identity - Complete AWS IAM Reference
Action Description Conditions cognito‑identity:CreateIdentityPool Creates a new identity pool. Global Conditions cognito‑identity:DeleteIdentityPool Deletes a user pool. Global Conditions cognito‑identity:DeleteIdentities Deletes identities from an identity pool. Global...
Read more >
Use an existing Cognito User Pool and Identity Pool
Import existing Amazon Cognito resources into your Amplify project. Get started by running amplify import auth command to search for & import an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found