Created
August 26, 2017 14:21
-
-
Save charltoons/9f13f7c4993420ca23013ee33a3a4619 to your computer and use it in GitHub Desktop.
AWS Cognito Lambda PreSignup Auto-Confirm Trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.handler = (event, context, callback) => { | |
console.log('Received event:', JSON.stringify(event, null, 2)) | |
const modifiedEvent = event | |
// check that we're acting on the right trigger | |
if (event.triggerSource === "PreSignUp_SignUp"){ | |
// auto confirm the user | |
modifiedEvent.response.autoConfirmUser = true | |
callback(null, modifiedEvent) | |
return | |
} | |
// Throw an error if invoked from the wrong trigger | |
callback(`Misconfigured Cognito Trigger ${ event.triggerSource }`) | |
}; |
@mattysads this little trick will suppress linter errors that tell you not to modify function arguments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's no reason to call
const modifiedEvent = event
Reassigning a reference does not affect the underlying object. Event is still modified here and cognito is fine with that