Reputation: 71
I'm creating a lambda function using nodejs to trigger codebuild project, here what I did so far but still with no luck.
exports.handler = async (event) => {
const AWS = require("aws-sdk");
const codebuild = new AWS.CodeBuild();
const build = {
projectName: "MyCodeBuildProjectName"
};
codebuild.startBuild(build,function(err, data){
if (err) {
console.log("Inside Error!");
console.log(err, err.stack);
}
else {
console.log("Outside Error!");
console.log(data);
}
});
};
When I'm running a test on this function I'm not getting neither of the "Inside Erro!" nor "Outside Error!" console log.
Am I missing something?
Upvotes: 4
Views: 4245
Reputation: 835
I was able to solve it using await
as given below.
const data = await codebuild.startBuild(params).promise();
Upvotes: 2