Hi,
You can create a new user the specified user pool through the Amazon Cognito API's. Refer here for the API details : https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html.
If you are using the AWS SDK, then the guidance on how to do this is here: (This is JS, you can browse for the SDK for the programming language of your choice) https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html.
For Lambda, as you've mentioned above, if you want to create an user - then the sample is as provided below,
const AWS = require('aws-sdk');
const userPoolId = 'YOUR_USER_POOL_ID';
const clientId = 'YOUR_APP_CLIENT_ID';
const region = 'YOUR_REGION';
const cognito = new AWS.CognitoIdentityServiceProvider({ region });
const params = {
UserPoolId: userPoolId,
Username: 'NEW_USER_USERNAME',
DesiredDeliveryMediums: ['EMAIL'],
UserAttributes: [
{
Name: 'email',
Value: 'NEW_USER_EMAIL',
},
{
Name: 'name',
Value: 'NEW_USER_NAME',
},
{
Name: 'custom_attribute',
Value: 'CUSTOM_VALUE',
},
],
TemporaryPassword: 'TEMP_PASSWORD',
MessageAction: 'SUPPRESS',
};
cognito.adminCreateUser(params, (err, data) => {
if (err) {
console.log(err, err.stack);
} else {
console.log(data);
}
});
Please refer https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html and create the user pools and the necessary user attribute settings
Hope this helps
Relevant content
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 6 months ago