来自Lambda的AWS Cognito adminCreateUser [英] AWS Cognito adminCreateUser from Lambda
问题描述
我正在尝试从AWS Lambda在AWS用户池中创建用户
I'm trying to create a user in a AWS User Pool from an AWS Lambda
我尝试使用此脚本从似乎是官方JavascriptSDK获取AWS但无法使其正常运行。 http://docs.aws.amazon.com/ AWSJavaScriptSDK / latest / AWS / CognitoIdentityServiceProvider.html#adminCreateUser-property
I tried with this script took from what seems to be the official JavascriptSDK for the AWS but can't get it working. http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminCreateUser-property
我一直收到此错误:
TypeError:cognitoidentityserviceprovider.adminCreateUser不是函数
TypeError: cognitoidentityserviceprovider.adminCreateUser is not a function
'use strict'
const AWS= require('aws-sdk');
exports.handler = (event, context, callback) => {
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({apiVersion: '2016-04-18'});
var params = {
UserPoolId: 'eu-west-1_XXXXXXXX', /* required */
Username: 'me@example.com', /* required */
DesiredDeliveryMediums: [
'EMAIL'
],
ForceAliasCreation: false,
MessageAction: 'SUPPRESS',
TemporaryPassword: 'tempPassword1',
UserAttributes: [
{
Name: 'email', /* required */
Value: 'me@example.com'
},
{
Name: 'name', /* required */
Value: 'Me'
},
{
Name: 'last_name', /* required */
Value: 'lastme'
}
/* more items */
]
};
cognitoidentityserviceprovider.adminCreateUser(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
callback(null, data);
});
};
推荐答案
对不起,我们深表歉意。您收到此错误是因为Lambda当前没有使用最新的JS SDK运行其执行环境。在更新之前,您应该可以通过手动拉入最新版本来解决此问题。
Sorry for the issues. You're getting this error because Lambda isn't currently running their execution environment with the most recent JS SDK. Until that is updated, you should be able to work around this by manually pulling in the most recent version.
这篇关于来自Lambda的AWS Cognito adminCreateUser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!