admittedly, this is my first attempt at doing anything with Cognito, but I am having trouble adding a user to a user group via lambda. here is the lambda code:
var AWS = require('aws-sdk');
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({apiVersion: '2016-04-18'});
exports.handler = (event, context, callback) => {
var params = {
GroupName: 'ROLE_ADMIN',
// UserPoolId: 'arn:aws:cognito-idp:us-east-1:23453453453:userpool/us-east-1_XXX',
UserPoolId: 'us-east-1_XXX',
// Username: '[email protected]'
Username: 'ec12f604-a83c-4c76-856b-3acd9ca70562'
}
console.log('before')
cognitoidentityserviceprovider.adminAddUserToGroup(params, function(err, data) {
console.log(params)
if (err) console.log("Error");
else console.log("Success");
});
console.log('after')
console.log("Executed.");
context.succeed(event);
};
I have added the AWS resources to the lambda
Amazon CloudWatch Logs Amazon Cognito Identity Amazon Cognito Sync Amazon Cognito User Pools Amazon SNS Identity And Access Management
here is the output:
Function Logs: START RequestId: e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 Version: $LATEST 2019-10-29T19:04:58.516Z e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 INFO before 2019-10-29T19:04:59.017Z e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 INFO after 2019-10-29T19:04:59.018Z e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 INFO Executed. END RequestId: e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 REPORT RequestId: e6fb3c51-3928-40e1-b0c4-f7a2d9054ef0 Duration: 657.73 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 37 MB Init Duration: 464.08 ms
what I am not seeing is the cognitoidentityserviceprovider.adminAddUserToGroup
being called, and the test runs, but it doesn't look like any uses are being added to the ROLE_ADMIN
group. what should I be doing to be adding users into a group?
any input would be greatly appreciated... thanks.