Skip to content

Project

Source: src/AWS/CodeBuild/Project.ts

An AWS CodeBuild build project — a reusable definition of how to run a build: the source, the build container, the compute size, the IAM role, and where artifacts land.

The project is a definition only; creating it is instant and free. Running a build (StartBuild) provisions compute and is billed per build-minute.

NO_SOURCE Project with an Inline Buildspec

const project = yield* CodeBuild.Project("Hello", {
serviceRole: role.roleArn,
source: {
type: "NO_SOURCE",
buildspec: [
"version: 0.2",
"phases:",
" build:",
" commands:",
" - echo Hello from CodeBuild",
].join("\n"),
},
environment: {
image: "aws/codebuild/amazonlinux2-x86_64-standard:5.0",
computeType: "BUILD_GENERAL1_SMALL",
},
});

S3-Source Project with S3 Artifacts

const project = yield* CodeBuild.Project("Packager", {
serviceRole: role.roleArn,
source: { type: "S3", location: `${bucket.bucketName}/source.zip` },
artifacts: { type: "S3", location: bucket.bucketName, name: "out.zip", packaging: "ZIP" },
environment: {
image: "aws/codebuild/amazonlinux2-x86_64-standard:5.0",
environmentVariables: [{ name: "STAGE", value: "prod" }],
},
});