@keybittech/awayto
Version:
Deploy a fully-featured application in about 10 minutes that is primed for quick development. Do business, impress a client with a quick demo, finish your poc with time to spare; all easily achievable with Awayto.
53 lines (42 loc) • 1.28 kB
JavaScript
import { CognitoIdentityProviderClient, SignUpCommand, AdminConfirmSignUpCommand, AddCustomAttributesCommand } from '@aws-sdk/client-cognito-identity-provider';
import { ask } from './tool.mjs'
const cipClient = new CognitoIdentityProviderClient();
export default async function(props = {}) {
let install = !!Object.keys(props).length;
if (!install) {
props = {
clientId: await ask('Client Id:\n> '),
poolId: await ask('Pool Id:\n> '),
username: await ask('Username:\n> '),
password: await ask('Password:\n> '),
email: await ask('Email:\n> ')
}
}
try {
const adminAccount = await cipClient.send(new SignUpCommand({
ClientId: props.clientId,
Username: props.username,
Password: props.password,
UserAttributes: [
{
Name: 'email',
Value: props.email
},
{
Name: 'custom:admin',
Value: 'system:admin'
}
]
}));
await cipClient.send(new AdminConfirmSignUpCommand({
UserPoolId: props.poolId,
Username: props.username
}));
return adminAccount;
} catch (error) {
console.log(error);
}
if (!install) {
process.exit();
}
}