I'm trying to create a lambda function to create new IAM user in AWS using Nodejs SDK, the function iam.createUser()
works great but I couldn't retrieve the callback data before my function finishes. I'm not familiar with Nodejs so here I am asking for experts' help.
Here's the piece of code where I call createUser()
:
var retMessage = '';
var params = {
UserName: "foo.bar";
};
iam.createUser(params, function(err, data) {
if (err) {
retMessage = err;
} else {
retMessage = data;
}
});
console.log(retMessage);
When my function finishes, all i got from retMessage
is null.
So how do I get those callback values?