我正在使用AWS Lambda函数(使用nodejs)。
从APP发送到Cognito的任何请求以注册用户。然后,我设置了“ 预注册”触发器来验证用户的客户,并检查我们数据库中是否有可用的用户自定义属性。如果是,则返回错误,否则将新记录插入数据库并将事件返回给Cognito。
TimeoutInfo-5分钟。
它在请求中的某个时间发生,而不是一直发生。RequestId为不同的。(它将在某个时间触发3次,大部分时间两次)
Lambda触发代码如下。
用户/ index.js
const handler = async (event, context) => {
log.info('createUserLambda:start');
// immediately return once the call back is called to avoid
// lambda time out because of any open db connections
context.callbackWaitsForEmptyEventLoop = false;
return await preUserCreate(event);
};
Run Code Online (Sandbox Code Playgroud)
Exports.handler =处理程序; users / users.js
export const preUserCreate = async (event) => {
log.info('preUserCreate:Start');
let userAttributes = event.request.userAttributes;
const currentDate = moment().utc().format('YYYY-MM-DD HH:mm:ss');
try {
let userParams = {
'docStatus': 'VRF'
};
let …Run Code Online (Sandbox Code Playgroud)