Refer to existing Cognito User Pool with ARN instead of pool name
See original GitHub issueUse 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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
any update on this?
@fredericbarthelet definitely! Still let’s cover that with two distinct PR’s