简体   繁体   English

Amazon Lambda function 和 Cognito:使用 lambda ZC1C4254268E68384F1AAB1C44425268E68384F1A1B1C1C42542068E68384F111000000000000000000000000000000000000000的新用户在现有用户池中添加新用户。

[英]Amazon Lambda function and Cognito : Add new user in existing user pool using a lambda function

I would know if we can create a lambda function to add a new user to a specific user pool, if yes have you any example that explain which role to create for this lambda function using nodeJs?. I would know if we can create a lambda function to add a new user to a specific user pool, if yes have you any example that explain which role to create for this lambda function using nodeJs?.

If i understood your question correctly follow these steps:如果我正确理解了您的问题,请按照以下步骤操作:

  • In your aws console navigate to "Identity and Access Management (IAM)"在您的 aws 控制台中导航到“身份和访问管理 (IAM)”
  • Select "Roles" and look for your lambda function, click on it. Select“角色”并寻找您的 lambda function,点击它。
  • Under "Permissions" click on "Attach Policies" and look for "AmazonCognitoPowerUser", this policy will give your lambda full access to Cognito User Pools.在“权限”下单击“附加策略”并查找“AmazonCognitoPowerUser”,此策略将授予您的 lambda 对 Cognito 用户池的完全访问权限。

Create new user code example:创建新的用户代码示例:

const aws = require('aws-sdk');
const cognito = new aws.CognitoIdentityServiceProvider();
const params = {
    ClientId: "The ID of the client associated with the user pool",
    Username: "My Username",
    Password: "My Password",
};
cognito.signUp(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Take a look at this api documentation 看看这个 api 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM