# IProject

Extends: IProject
Extends: IResource, IGrantable, IConnectable, INotificationRuleSource, IProjectRef
Implemented by: PipelineProject, Project

- Source: [`aws-codebuild/lib/project.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codebuild/lib/project.ts#L83)
- Type last changed: v2.234.0 · 8 Jan 2026

## Properties

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — The network connections associated with this resource.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `grantPrincipal`: [IPrincipal](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IPrincipal.html) — The principal to grant permissions to.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `projectArn`: string — The ARN of this Project.

- `projectName`: string — The human-visible name of this Project.

- `projectRef`: [ProjectReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_codebuild.ProjectReference.html) — A reference to a Project resource.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM service Role of this Project.

  Undefined for imported Projects.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addToRolePolicy(policyStatement: PolicyStatement): void`

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `bindAsNotificationRuleSource(scope: Construct): NotificationRuleSourceConfig` — Returns a source configuration for notification rule.

- `enableBatchBuilds(): BatchBuildConfig` — Enable batch builds.

  Returns an object contining the batch service role if batch builds
  could be enabled.

- `metric(metricName: string, props?: MetricOptions): Metric`

  **Parameters**

  - `metricName` — The name of the metric.
  - `props` — Customization properties.

  **Returns:** a CloudWatch metric associated with this build project.

- `metricBuilds(props?: MetricOptions): Metric` — Measures the number of builds triggered.

  Units: Count

  Valid CloudWatch statistics: Sum

- `metricDuration(props?: MetricOptions): Metric` — Measures the duration of all builds over time.

  Units: Seconds

  Valid CloudWatch statistics: Average (recommended), Maximum, Minimum

- `metricFailedBuilds(props?: MetricOptions): Metric` — Measures the number of builds that failed because of client error or because of a timeout.

  Units: Count

  Valid CloudWatch statistics: Sum

- `metricSucceededBuilds(props?: MetricOptions): Metric` — Measures the number of successful builds.

  Units: Count

  Valid CloudWatch statistics: Sum

- `notifyOn(id: string, target: INotificationRuleTarget, options: ProjectNotifyOnOptions): INotificationRule` — Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to `onEvent` API.

  You can also use the methods `notifyOnBuildSucceeded` and
  `notifyOnBuildFailed` to define rules for these specific event emitted.

  **Parameters**

  - `id` — The logical identifier of the CodeStar Notifications rule that will be created.
  - `target` — The target to register for the CodeStar Notifications destination.
  - `options` — Customization options for CodeStar Notifications rule.

  **Returns:** CodeStar Notifications rule associated with this build project.

- `notifyOnBuildFailed(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule` — Defines a CodeStar notification rule which triggers when a build fails.

- `notifyOnBuildSucceeded(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule` — Defines a CodeStar notification rule which triggers when a build completes successfully.

- `onBuildFailed(id: string, options?: OnEventOptions): Rule` — Defines an event rule which triggers when a build fails.

- `onBuildStarted(id: string, options?: OnEventOptions): Rule` — Defines an event rule which triggers when a build starts.

- `onBuildSucceeded(id: string, options?: OnEventOptions): Rule` — Defines an event rule which triggers when a build completes successfully.

- `onEvent(id: string, options?: OnEventOptions): Rule` — Defines a CloudWatch event rule triggered when something happens with this project.

- `onPhaseChange(id: string, options?: OnEventOptions): Rule` — Defines a CloudWatch event rule that triggers upon phase change of this build project.

- `onStateChange(id: string, options?: OnEventOptions): Rule` — Defines a CloudWatch event rule triggered when the build project state changes.

  You can filter specific build status events using an event
  pattern filter on the `build-status` detail field:

     const rule = project.onStateChange('OnBuildStarted', { target });
     rule.addEventPattern({
       detail: {
         'build-status': [
           "IN_PROGRESS",
           "SUCCEEDED",
           "FAILED",
           "STOPPED"
         ]
       }
     });

  You can also use the methods `onBuildFailed` and `onBuildSucceeded` to define rules for
  these specific state changes.

  To access fields from the event in the event target input,
  use the static fields on the `StateChangeEvent` class.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
