# CodeBuildProject

Start a CodeBuild build when an Amazon EventBridge rule is triggered.

Extends: CodeBuildProject
Implements: IRuleTarget

- Source: [`aws-events-targets/lib/codebuild.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-events-targets/lib/codebuild.ts#L33)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

```ts
import * as sns from 'aws-cdk-lib/aws-sns';
import * as targets from 'aws-cdk-lib/aws-events-targets';

declare const repo: codecommit.Repository;
declare const project: codebuild.PipelineProject;
declare const myTopic: sns.Topic;

// starts a CodeBuild project when a commit is pushed to the "main" branch of the repo
repo.onCommit('CommitToMain', {
  target: new targets.CodeBuildProject(project),
  branches: ['main'],
});

// publishes a message to an Amazon SNS topic when a comment is made on a pull request
const rule = repo.onCommentOnPullRequest('CommentOnPullRequest', {
  target: new targets.SnsTopic(myTopic),
});
```

## Initializer

```ts
new CodeBuildProject(project: IProjectRef, props?: CodeBuildProjectProps)
```

## Methods

- `bind(_rule: IRuleRef, _id?: string): RuleTargetConfig` — Allows using build projects as event rule targets.
