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?
Solved by taking "async" out from the first line.
I was able to solve it using await as given below.
const data = await codebuild.startBuild(params).promise();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With