我们一直在尝试在Cognito用户池中创建用户,但仍然遇到一个相当奇怪的错误。堆栈跟踪如下所示:
{
"errorMessage": "Not Found",
"errorType": "UnknownError",
"stackTrace": [
"Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:48:27)",
"Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:105:20)",
"Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10)",
"Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)",
"Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)",
"AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)",
"/var/task/node_modules/aws-sdk/lib/state_machine.js:26:10",
"Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)",
"Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)",
"Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:115:18)"
]
}
这是我们在Lambda中执行的代码。 Lambda函数本身由API网关调用,无需代理集成。
const AWS = require('aws-sdk');
AWS.config.update({
region: "ap-south-1",
endpoint: "https://dynamodb.ap-south-1.amazonaws.com",
});
const docClient = new AWS.DynamoDB.DocumentClient();
const cispClient = new AWS.CognitoIdentityServiceProvider({
region: 'us-east-1'
});
const table = process.env.TABLE_NAME || "User_Info_Test";
exports.newDriverCreated = function (event, context) {
console.log('event: ', event);
// Get username, password
const username = event.username;
const password = event.password;
// Get first and last name
const firstName = event.name;
const lastName = event.family_name;
// Get phone number
const phone = event.phone;
const driverData = {
"TemporaryPassword": password,
"UserAttributes": [
{
"Name": "phone_number",
"Value": phone,
},
{
"Name": "first_name",
"Value": firstName,
},
{
"Name": "family_name",
"Value": lastName,
},
],
"Username": username,
"UserPoolId": 'user-pool-id',
"ValidationData": [
{
"Name": "phone_number",
"Value": phone
}
]
}
cispClient.adminCreateUser(driverData, (err, data) => {
if (err) {
console.error('adminCreateUser error: ', err);
context.done(err);
} else {
console.log('adminCreateUser data: ', data);
context.done(null, data);
}
});
}
当我们调用adminCreateUser()
函数时发生错误。我们完全不知道可能出现什么问题,因为我们对整个AWS都是新手。
非常感谢任何帮助。
感谢。
答案 0 :(得分:0)
在创建cispClient时尝试提及端点。由于端点不正确,它看起来可能是一个问题。请参阅this和enter link description here。查看here以获取端点列表。