-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
Description
When creating a Function which responds to Cognito events, like this:
Events:
UserPoolPreAuthentication:
Type: Cognito
Properties:
UserPool: !Ref TheUserPool
Trigger: PreAuthentication
...the transformation includes this permission:
"TheFunctionCognitoPermission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"FunctionName": {
"Ref": "TheFunction"
},
"EventSourceToken": {
"Ref": "TheUserPool"
},
"Principal": "cognito-idp.amazonaws.com"
}
}
...which I believe is incorrect and causing invocations to fail, blocking (pre-)authentication. The EventSourceToken
appears only to be used for Alexa something-something. Permissions for invocation by Cognito should be using SourceArn
. (With Fn:GetAtt
of the Arn
of TheUserPool
, natch.)
Steps to Reproduce
- Create a SAM template which responds to Cognito events.
- Attempt to log in to a Cognito User Pool protected resource.
- Note that the error response includes an description of "PreAuthentication invocation failed due to error AccessDeniedException".
Observed Result
The Function is never invoked. Its CloudWatch log stream is never even created.
Expected Result
The, uh, the Function is invoked? I'm not sure what to put here. I'd expect the AWS::Lambda::Permission
resource to be well-formed and correct for the service which is expected to be performing the invocation, I guess?