4

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?

2 Answers 2

3

Solved by taking "async" out from the first line.

Sign up to request clarification or add additional context in comments.

Comments

2

I was able to solve it using await as given below.

const data = await codebuild.startBuild(params).promise();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.