Lambda Function that runs CodeBuild after something is uploaded to S3?

Is it possible, using Serverless, to create a lambda function that runs CodeBuild after a .zip file is uploaded to S3?
I want to run code evaluation for different people using NodeJS. So what I want is, after someone sends their Zipped code, CodeBuild runs that code, build it, and runs tests.
I got all steps covered, but this one. I don’t know how to make a lambda function to execute a CodeBuild script. Is it possible?

Thanks.

Almost certainly.

You can trigger a lambda when a file is uploaded to S3 (see Serverless Framework - AWS Lambda Events - S3)

You can use the AWS SDK to interact with CodeBuild to create projects and start builds (see Class: AWS.CodeBuild — AWS SDK for JavaScript).

2 Likes