Skip to content

Commit

Permalink
JS v3 added Cognito->AdminCreateUser sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachjonesnoel committed Sep 28, 2021
1 parent 1d230ac commit 3470538
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions javascriptv3/example_code/cognito/admin-create-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
ABOUT THIS NODE.JS EXAMPLE: This example works with AWS SDK for JavaScript version 3 (v3)
Purpose:
admin-create-user.js demonstrates how to create an user from Cognito SDK.
*/

//snippet-sourcedescription:[admin-create-user.js demonstrates demonstrates how to create an user from Cognito SDK.]
//snippet-service:[cognito]
//snippet-keyword:[JavaScript]
//snippet-sourcesyntax:[javascript]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Cognito]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2021-09-28]
//snippet-sourceauthor:[zachjonesnoel]

// ABOUT THIS NODE.JS SAMPLE: This sample is part of the SDK for JavaScript Developer Guide topic at
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminCreateUser-property

// snippet-start:[ses.JavaScript.filters.admin-create-user]
// Load the AWS SDK for Node.js.
var AWS = require('aws-sdk');
// Set the AWS Region.
AWS.config.update({ region: 'REGION' });
// Initialize CogntioIdentityServiceProvider SDK.
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
var params = {
UserPoolId: "UserPoolID",
Username: "[email protected]",
DesiredDeliveryMediums: [
"EMAIL"
],
MessageAction: "RESEND",
TemporaryPassword: "Password@123",
UserAttributes: [
{
Name: "email",
Value: "[email protected]"
}
]
}
var response = await cognitoidentityserviceprovider.adminCreateUser(params).promise()
console.log(JSON.stringify(response, null, 2))
// snippet-end:[ses.JavaScript.filters.admin-create-user]

0 comments on commit 3470538

Please sign in to comment.