# AWS CodeBuild Construct Library

AWS CodeBuild is a fully managed continuous integration service that compiles
source code, runs tests, and produces software packages that are ready to
deploy. With CodeBuild, you don’t need to provision, manage, and scale your own
build servers. CodeBuild scales continuously and processes multiple builds
concurrently, so your builds are not left waiting in a queue. You can get
started quickly by using prepackaged build environments, or you can create
custom build environments that use your own build tools. With CodeBuild, you are
charged by the minute for the compute resources you use.

## Source

Build projects are usually associated with a _source_, which is specified via
the `source` property which accepts a class that extends the [`Source`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Source.html)
abstract base class.
The default is to have no source associated with the build project;
the `buildSpec` option is required in that case.

Here's a CodeBuild project with no source which simply prints `Hello,
CodeBuild!`:

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: [
          'echo "Hello, CodeBuild!"',
        ],
      },
    },
  }),
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["echo \"Hello, CodeBuild!\""
                ]
            }
        }
    })
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("echo \"Hello, CodeBuild!\""))))))
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "echo \"Hello, CodeBuild!\"" }
            } }
        } }
    })
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("echo \"Hello, CodeBuild!\""),
				},
			},
		},
	}),
})
```

### `CodeCommitSource`

Use an AWS CodeCommit repository as the source of this build:

TypeScript:

```ts
import * as codecommit from 'aws-cdk-lib/aws-codecommit';

const repository = new codecommit.Repository(this, 'MyRepo', { repositoryName: 'foo' });
new codebuild.Project(this, 'MyFirstCodeCommitProject', {
  source: codebuild.Source.codeCommit({ repository }),
});
```

Python:

```python
import aws_cdk.aws_codecommit as codecommit

repository = codecommit.Repository(self, "MyRepo", repository_name="foo")
codebuild.Project(self, "MyFirstCodeCommitProject",
    source=codebuild.Source.code_commit(repository=repository)
)
```

Java:

```java
import software.amazon.awscdk.services.codecommit.*;

Repository repository = Repository.Builder.create(this, "MyRepo").repositoryName("foo").build();
Project.Builder.create(this, "MyFirstCodeCommitProject")
        .source(Source.codeCommit(CodeCommitSourceProps.builder().repository(repository).build()))
        .build();
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.CodeCommit;

var repository = new Repository(this, "MyRepo", new RepositoryProps { RepositoryName = "foo" });
new Project(this, "MyFirstCodeCommitProject", new ProjectProps {
    Source = Source.CodeCommit(new CodeCommitSourceProps { Repository = repository })
});
```

Golang:

```go
import codecommit "github.com/aws/aws-cdk-go/awscdk"

repository := codecommit.NewRepository(this, jsii.String("MyRepo"), &RepositoryProps{
	RepositoryName: jsii.String("foo"),
})
codebuild.NewProject(this, jsii.String("MyFirstCodeCommitProject"), &ProjectProps{
	Source: codebuild.Source_CodeCommit(&CodeCommitSourceProps{
		Repository: *Repository,
	}),
})
```

### `S3Source`

Create a CodeBuild project with an S3 bucket as the source:

TypeScript:

```ts
const bucket = new s3.Bucket(this, 'MyBucket');

new codebuild.Project(this, 'MyProject', {
  source: codebuild.Source.s3({
    bucket: bucket,
    path: 'path/to/file.zip',
  }),
});
```

Python:

```python
bucket = s3.Bucket(self, "MyBucket")

codebuild.Project(self, "MyProject",
    source=codebuild.Source.s3(
        bucket=bucket,
        path="path/to/file.zip"
    )
)
```

Java:

```java
Bucket bucket = new Bucket(this, "MyBucket");

Project.Builder.create(this, "MyProject")
        .source(Source.s3(S3SourceProps.builder()
                .bucket(bucket)
                .path("path/to/file.zip")
                .build()))
        .build();
```

C# / .NET:

```csharp
var bucket = new Bucket(this, "MyBucket");

new Project(this, "MyProject", new ProjectProps {
    Source = Source.S3(new S3SourceProps {
        Bucket = bucket,
        Path = "path/to/file.zip"
    })
});
```

Golang:

```go
bucket := s3.NewBucket(this, jsii.String("MyBucket"))

codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Source: codebuild.Source_S3(&S3SourceProps{
		Bucket: bucket,
		Path: jsii.String("path/to/file.zip"),
	}),
})
```

The CodeBuild role will be granted to read just the given path from the given `bucket`.

### `GitHubSource` and `GitHubEnterpriseSource`

These source types can be used to build code from a GitHub repository.
Example:

TypeScript:

```ts
const gitHubSource = codebuild.Source.gitHub({
  owner: 'awslabs',
  repo: 'aws-cdk', // optional, default: undefined if unspecified will create organization webhook
  webhook: true, // optional, default: true if `webhookFilters` were provided, false otherwise
  webhookTriggersBatchBuild: true, // optional, default is false
  webhookFilters: [
    codebuild.FilterGroup
      .inEventOf(codebuild.EventAction.PUSH)
      .andBranchIs('main')
      .andCommitMessageIs('the commit message'),
    codebuild.FilterGroup
      .inEventOf(codebuild.EventAction.RELEASED)
      .andBranchIs('main')
  ], // optional, by default all pushes and Pull Requests will trigger a build
});
```

Python:

```python
git_hub_source = codebuild.Source.git_hub(
    owner="awslabs",
    repo="aws-cdk",  # optional, default: undefined if unspecified will create organization webhook
    webhook=True,  # optional, default: true if `webhookFilters` were provided, false otherwise
    webhook_triggers_batch_build=True,  # optional, default is false
    webhook_filters=[
        codebuild.FilterGroup.in_event_of(codebuild.EventAction.PUSH).and_branch_is("main").and_commit_message_is("the commit message"),
        codebuild.FilterGroup.in_event_of(codebuild.EventAction.RELEASED).and_branch_is("main")
    ]
)
```

Java:

```java
ISource gitHubSource = Source.gitHub(GitHubSourceProps.builder()
        .owner("awslabs")
        .repo("aws-cdk") // optional, default: undefined if unspecified will create organization webhook
        .webhook(true) // optional, default: true if `webhookFilters` were provided, false otherwise
        .webhookTriggersBatchBuild(true) // optional, default is false
        .webhookFilters(List.of(FilterGroup.inEventOf(EventAction.PUSH).andBranchIs("main").andCommitMessageIs("the commit message"), FilterGroup.inEventOf(EventAction.RELEASED).andBranchIs("main")))
        .build());
```

C# / .NET:

```csharp
var gitHubSource = Source.GitHub(new GitHubSourceProps {
    Owner = "awslabs",
    Repo = "aws-cdk",  // optional, default: undefined if unspecified will create organization webhook
    Webhook = true,  // optional, default: true if `webhookFilters` were provided, false otherwise
    WebhookTriggersBatchBuild = true,  // optional, default is false
    WebhookFilters = new [] { FilterGroup.InEventOf(EventAction.PUSH).AndBranchIs("main").AndCommitMessageIs("the commit message"), FilterGroup.InEventOf(EventAction.RELEASED).AndBranchIs("main") }
});
```

Golang:

```go
gitHubSource := codebuild.Source_GitHub(&GitHubSourceProps{
	Owner: jsii.String("awslabs"),
	Repo: jsii.String("aws-cdk"),
	 // optional, default: undefined if unspecified will create organization webhook
	Webhook: jsii.Boolean(true),
	 // optional, default: true if `webhookFilters` were provided, false otherwise
	WebhookTriggersBatchBuild: jsii.Boolean(true),
	 // optional, default is false
	WebhookFilters: []FilterGroup{
		codebuild.FilterGroup_InEventOf(codebuild.EventAction_PUSH).AndBranchIs(jsii.String("main")).AndCommitMessageIs(jsii.String("the commit message")),
		codebuild.FilterGroup_*InEventOf(codebuild.EventAction_RELEASED).*AndBranchIs(jsii.String("main")),
	},
})
```

The `GitHubSource` is also able to trigger all repos in GitHub Organizations
Example:

TypeScript:

```ts
const gitHubSource = codebuild.Source.gitHub({
  owner: 'aws',
  webhookTriggersBatchBuild: true, // optional, default is false
  webhookFilters: [
    codebuild.FilterGroup
      .inEventOf(codebuild.EventAction.WORKFLOW_JOB_QUEUED)
      .andRepositoryNameIs("aws-.*")
      .andRepositoryNameIsNot("aws-cdk-lib"),
  ], // optional, by default all pushes and Pull Requests will trigger a build
});
```

Python:

```python
git_hub_source = codebuild.Source.git_hub(
    owner="aws",
    webhook_triggers_batch_build=True,  # optional, default is false
    webhook_filters=[
        codebuild.FilterGroup.in_event_of(codebuild.EventAction.WORKFLOW_JOB_QUEUED).and_repository_name_is("aws-.*").and_repository_name_is_not("aws-cdk-lib")
    ]
)
```

Java:

```java
ISource gitHubSource = Source.gitHub(GitHubSourceProps.builder()
        .owner("aws")
        .webhookTriggersBatchBuild(true) // optional, default is false
        .webhookFilters(List.of(FilterGroup.inEventOf(EventAction.WORKFLOW_JOB_QUEUED).andRepositoryNameIs("aws-.*").andRepositoryNameIsNot("aws-cdk-lib")))
        .build());
```

C# / .NET:

```csharp
var gitHubSource = Source.GitHub(new GitHubSourceProps {
    Owner = "aws",
    WebhookTriggersBatchBuild = true,  // optional, default is false
    WebhookFilters = new [] { FilterGroup.InEventOf(EventAction.WORKFLOW_JOB_QUEUED).AndRepositoryNameIs("aws-.*").AndRepositoryNameIsNot("aws-cdk-lib") }
});
```

Golang:

```go
gitHubSource := codebuild.Source_GitHub(&GitHubSourceProps{
	Owner: jsii.String("aws"),
	WebhookTriggersBatchBuild: jsii.Boolean(true),
	 // optional, default is false
	WebhookFilters: []FilterGroup{
		codebuild.FilterGroup_InEventOf(codebuild.EventAction_WORKFLOW_JOB_QUEUED).AndRepositoryNameIs(jsii.String("aws-.*")).AndRepositoryNameIsNot(jsii.String("aws-cdk-lib")),
	},
})
```

To provide GitHub credentials, please either go to AWS CodeBuild Console to connect
or call `ImportSourceCredentials` to persist your personal access token.
Example:

```console
aws codebuild import-source-credentials --server-type GITHUB --auth-type PERSONAL_ACCESS_TOKEN --token <token_value>
```

### `BitBucketSource`

This source type can be used to build code from a BitBucket repository.

TypeScript:

```ts
const bbSource = codebuild.Source.bitBucket({
  owner: 'owner',
  repo: 'repo',
});
```

Python:

```python
bb_source = codebuild.Source.bit_bucket(
    owner="owner",
    repo="repo"
)
```

Java:

```java
ISource bbSource = Source.bitBucket(BitBucketSourceProps.builder()
        .owner("owner")
        .repo("repo")
        .build());
```

C# / .NET:

```csharp
var bbSource = Source.BitBucket(new BitBucketSourceProps {
    Owner = "owner",
    Repo = "repo"
});
```

Golang:

```go
bbSource := codebuild.Source_BitBucket(&BitBucketSourceProps{
	Owner: jsii.String("owner"),
	Repo: jsii.String("repo"),
})
```

### For all Git sources

For all Git sources, you can fetch submodules while cloning git repo.

TypeScript:

```ts
const gitHubSource = codebuild.Source.gitHub({
  owner: 'awslabs',
  repo: 'aws-cdk',
  fetchSubmodules: true,
});
```

Python:

```python
git_hub_source = codebuild.Source.git_hub(
    owner="awslabs",
    repo="aws-cdk",
    fetch_submodules=True
)
```

Java:

```java
ISource gitHubSource = Source.gitHub(GitHubSourceProps.builder()
        .owner("awslabs")
        .repo("aws-cdk")
        .fetchSubmodules(true)
        .build());
```

C# / .NET:

```csharp
var gitHubSource = Source.GitHub(new GitHubSourceProps {
    Owner = "awslabs",
    Repo = "aws-cdk",
    FetchSubmodules = true
});
```

Golang:

```go
gitHubSource := codebuild.Source_GitHub(&GitHubSourceProps{
	Owner: jsii.String("awslabs"),
	Repo: jsii.String("aws-cdk"),
	FetchSubmodules: jsii.Boolean(true),
})
```

## BuildSpec

The build spec can be provided from a number of different sources

### File path relative to the root of the source

You can specify a specific filename that exists within the project's source artifact to use as the buildspec.

TypeScript:

```ts
const project = new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromSourceFilename('my-buildspec.yml'),
  source: codebuild.Source.gitHub({
    owner: 'awslabs',
    repo: 'aws-cdk',
  })
});
```

Python:

```python
project = codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_source_filename("my-buildspec.yml"),
    source=codebuild.Source.git_hub(
        owner="awslabs",
        repo="aws-cdk"
    )
)
```

Java:

```java
Project project = Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromSourceFilename("my-buildspec.yml"))
        .source(Source.gitHub(GitHubSourceProps.builder()
                .owner("awslabs")
                .repo("aws-cdk")
                .build()))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromSourceFilename("my-buildspec.yml"),
    Source = Source.GitHub(new GitHubSourceProps {
        Owner = "awslabs",
        Repo = "aws-cdk"
    })
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromSourceFilename(jsii.String("my-buildspec.yml")),
	Source: codebuild.Source_GitHub(&GitHubSourceProps{
		Owner: jsii.String("awslabs"),
		Repo: jsii.String("aws-cdk"),
	}),
})
```

This will use `my-buildspec.yml` file within the `awslabs/aws-cdk` repository as the build spec.

### File within the CDK project codebuild

You can also specify a file within your cdk project directory to use as the buildspec.

TypeScript:

```ts
const project = new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromAsset('my-buildspec.yml'),
});
```

Python:

```python
project = codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_asset("my-buildspec.yml")
)
```

Java:

```java
Project project = Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromAsset("my-buildspec.yml"))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromAsset("my-buildspec.yml")
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromAsset(jsii.String("my-buildspec.yml")),
})
```

This file will be uploaded to S3 and referenced from the codebuild project.

### Inline object

TypeScript:

```ts
const project = new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
  }),
});
```

Python:

```python
project = codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2"
    })
)
```

Java:

```java
Project project = Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2")))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" }
    })
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
	}),
})
```

This will result in the buildspec being rendered as JSON within the codebuild project, if you prefer it to be rendered as YAML, use `fromObjectToYaml`.

TypeScript:

```ts
const project = new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromObjectToYaml({
    version: '0.2',
  }),
});
```

Python:

```python
project = codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_object_to_yaml({
        "version": "0.2"
    })
)
```

Java:

```java
Project project = Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromObjectToYaml(Map.of(
                "version", "0.2")))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromObjectToYaml(new Dictionary<string, object> {
        { "version", "0.2" }
    })
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObjectToYaml(map[string]interface{}{
		"version": jsii.String("0.2"),
	}),
})
```

## Artifacts

CodeBuild Projects can produce Artifacts and upload them to S3. For example:

TypeScript:

```ts
declare const bucket: s3.Bucket;

const project = new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
  }),
  artifacts: codebuild.Artifacts.s3({
      bucket,
      includeBuildId: false,
      packageZip: true,
      path: 'another/path',
      identifier: 'AddArtifact1',
    }),
});
```

Python:

```python
# bucket: s3.Bucket

project = codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2"
    }),
    artifacts=codebuild.Artifacts.s3(
        bucket=bucket,
        include_build_id=False,
        package_zip=True,
        path="another/path",
        identifier="AddArtifact1"
    )
)
```

Java:

```java
Bucket bucket;

Project project = Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2")))
        .artifacts(Artifacts.s3(S3ArtifactsProps.builder()
                .bucket(bucket)
                .includeBuildId(false)
                .packageZip(true)
                .path("another/path")
                .identifier("AddArtifact1")
                .build()))
        .build();
```

C# / .NET:

```csharp
Bucket bucket;

var project = new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" }
    }),
    Artifacts = Artifacts.S3(new S3ArtifactsProps {
        Bucket = bucket,
        IncludeBuildId = false,
        PackageZip = true,
        Path = "another/path",
        Identifier = "AddArtifact1"
    })
});
```

Golang:

```go
var bucket Bucket

project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
	}),
	Artifacts: codebuild.Artifacts_S3(&S3ArtifactsProps{
		Bucket: *Bucket,
		IncludeBuildId: jsii.Boolean(false),
		PackageZip: jsii.Boolean(true),
		Path: jsii.String("another/path"),
		Identifier: jsii.String("AddArtifact1"),
	}),
})
```

Because we've not set the `name` property, this example will set the
`overrideArtifactName` parameter, and produce an artifact named as defined in
the Buildspec file, uploaded to an S3 bucket (`bucket`). The path will be
`another/path` and the artifact will be a zipfile.

## CodePipeline

To add a CodeBuild Project as an Action to CodePipeline,
use the [`PipelineProject`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.PipelineProject.html) class instead of [`Project`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Project.html).
It's a simple class that doesn't allow you to specify `sources`,
`secondarySources`, `artifacts` or `secondaryArtifacts`,
as these are handled by setting input and output CodePipeline `Artifact` instances on the Action,
instead of setting them on the Project.

TypeScript:

```ts
const project = new codebuild.PipelineProject(this, 'Project', {
  // properties as above...
})
```

Python:

```python
project = codebuild.PipelineProject(self, "Project")
```

Java:

```java
PipelineProject project = PipelineProject.Builder.create(this, "Project").build();
```

C# / .NET:

```csharp
var project = new PipelineProject(this, "Project", new PipelineProjectProps { });
```

Golang:

```go
project := codebuild.NewPipelineProject(this, jsii.String("Project"), &PipelineProjectProps{
})
```

For more details, see the readme of the `@aws-cdk/aws-codepipeline-actions` package.

## Caching

You can save time when your project builds by using a cache. A cache can store reusable pieces of your build environment and use them across multiple builds. Your build project can use one of two types of caching: Amazon S3 or local. In general, S3 caching is a good option for small and intermediate build artifacts that are more expensive to build than to download. Local caching is a good option for large intermediate build artifacts because the cache is immediately available on the build host.

### S3 Caching

With S3 caching, the cache is stored in an S3 bucket which is available
regardless from what CodeBuild instance gets selected to run your CodeBuild job
on. When using S3 caching, you must also add in a `cache` section to your
buildspec which indicates the files to be cached:

TypeScript:

```ts
declare const myCachingBucket: s3.Bucket;

new codebuild.Project(this, 'Project', {
  source: codebuild.Source.bitBucket({
    owner: 'awslabs',
    repo: 'aws-cdk',
  }),

  cache: codebuild.Cache.bucket(myCachingBucket),

  // BuildSpec with a 'cache' section necessary for S3 caching. This can
  // also come from 'buildspec.yml' in your source.
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: ['...'],
      },
    },
    cache: {
      paths: [
        // The '**/*' is required to indicate all files in this directory
        '/root/cachedir/**/*',
      ],
    },
  }),
});
```

Python:

```python
# my_caching_bucket: s3.Bucket

codebuild.Project(self, "Project",
    source=codebuild.Source.bit_bucket(
        owner="awslabs",
        repo="aws-cdk"
    ),

    cache=codebuild.Cache.bucket(my_caching_bucket),

    # BuildSpec with a 'cache' section necessary for S3 caching. This can
    # also come from 'buildspec.yml' in your source.
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["..."]
            }
        },
        "cache": {
            "paths": ["/root/cachedir/**/*"
            ]
        }
    })
)
```

Java:

```java
Bucket myCachingBucket;

Project.Builder.create(this, "Project")
        .source(Source.bitBucket(BitBucketSourceProps.builder()
                .owner("awslabs")
                .repo("aws-cdk")
                .build()))

        .cache(Cache.bucket(myCachingBucket))

        // BuildSpec with a 'cache' section necessary for S3 caching. This can
        // also come from 'buildspec.yml' in your source.
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("..."))),
                "cache", Map.of(
                        "paths", List.of("/root/cachedir/**/*")))))
        .build();
```

C# / .NET:

```csharp
Bucket myCachingBucket;

new Project(this, "Project", new ProjectProps {
    Source = Source.BitBucket(new BitBucketSourceProps {
        Owner = "awslabs",
        Repo = "aws-cdk"
    }),

    Cache = Cache.Bucket(myCachingBucket),

    // BuildSpec with a 'cache' section necessary for S3 caching. This can
    // also come from 'buildspec.yml' in your source.
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "..." }
            } }
        } },
        { "cache", new Dictionary<string, string[]> {
            { "paths", new [] { "/root/cachedir/**/*" } }
        } }
    })
});
```

Golang:

```go
var myCachingBucket Bucket

codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Source: codebuild.Source_BitBucket(&BitBucketSourceProps{
		Owner: jsii.String("awslabs"),
		Repo: jsii.String("aws-cdk"),
	}),

	Cache: codebuild.Cache_Bucket(myCachingBucket),

	// BuildSpec with a 'cache' section necessary for S3 caching. This can
	// also come from 'buildspec.yml' in your source.
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("..."),
				},
			},
		},
		"cache": map[string][]*string{
			"paths": []*string{
				jsii.String("/root/cachedir/**/*"),
			},
		},
	}),
})
```

If you want to [share the same cache between multiple projects](https://docs.aws.amazon.com/codebuild/latest/userguide/caching-s3.html#caching-s3-sharing), you must must do the following:

- Use the same `cacheNamespace`.
- Specify the same cache key.
- Define identical cache paths.
- Use the same Amazon S3 buckets and `pathPrefix` if set.

TypeScript:

```ts
declare const sourceBucket: s3.Bucket;
declare const myCachingBucket: s3.Bucket;

new codebuild.Project(this, 'ProjectA', {
  source: codebuild.Source.s3({
    bucket: sourceBucket,
    path: 'path/to/source-a.zip',
  }),
  // configure the same bucket and path prefix
  cache: codebuild.Cache.bucket(myCachingBucket, {
    prefix: 'cache',
    // use the same cache namespace
    cacheNamespace: 'cache-namespace',
  }),
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: ['...'],
      },
    },
    // specify the same cache key and paths
    cache: {
      key: 'unique-key',
      paths: [
        '/root/cachedir/**/*',
      ],
    },
  }),
});

new codebuild.Project(this, 'ProjectB', {
  source: codebuild.Source.s3({
    bucket: sourceBucket,
    path: 'path/to/source-b.zip',
  }),
  // configure the same bucket and path prefix
  cache: codebuild.Cache.bucket(myCachingBucket, {
    prefix: 'cache',
    // use the same cache namespace
    cacheNamespace: 'cache-namespace',
  }),
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: ['...'],
      },
    },
    // specify the same cache key and paths
    cache: {
      key: 'unique-key',
      paths: [
        '/root/cachedir/**/*',
      ],
    },
  }),
});
```

Python:

```python
# source_bucket: s3.Bucket
# my_caching_bucket: s3.Bucket

codebuild.Project(self, "ProjectA",
    source=codebuild.Source.s3(
        bucket=source_bucket,
        path="path/to/source-a.zip"
    ),
    # configure the same bucket and path prefix
    cache=codebuild.Cache.bucket(my_caching_bucket,
        prefix="cache",
        # use the same cache namespace
        cache_namespace="cache-namespace"
    ),
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["..."]
            }
        },
        # specify the same cache key and paths
        "cache": {
            "key": "unique-key",
            "paths": ["/root/cachedir/**/*"
            ]
        }
    })
)

codebuild.Project(self, "ProjectB",
    source=codebuild.Source.s3(
        bucket=source_bucket,
        path="path/to/source-b.zip"
    ),
    # configure the same bucket and path prefix
    cache=codebuild.Cache.bucket(my_caching_bucket,
        prefix="cache",
        # use the same cache namespace
        cache_namespace="cache-namespace"
    ),
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["..."]
            }
        },
        # specify the same cache key and paths
        "cache": {
            "key": "unique-key",
            "paths": ["/root/cachedir/**/*"
            ]
        }
    })
)
```

Java:

```java
Bucket sourceBucket;
Bucket myCachingBucket;

Project.Builder.create(this, "ProjectA")
        .source(Source.s3(S3SourceProps.builder()
                .bucket(sourceBucket)
                .path("path/to/source-a.zip")
                .build()))
        // configure the same bucket and path prefix
        .cache(Cache.bucket(myCachingBucket, BucketCacheOptions.builder()
                .prefix("cache")
                // use the same cache namespace
                .cacheNamespace("cache-namespace")
                .build()))
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("..."))),
                // specify the same cache key and paths
                "cache", Map.of(
                        "key", "unique-key",
                        "paths", List.of("/root/cachedir/**/*")))))
        .build();

Project.Builder.create(this, "ProjectB")
        .source(Source.s3(S3SourceProps.builder()
                .bucket(sourceBucket)
                .path("path/to/source-b.zip")
                .build()))
        // configure the same bucket and path prefix
        .cache(Cache.bucket(myCachingBucket, BucketCacheOptions.builder()
                .prefix("cache")
                // use the same cache namespace
                .cacheNamespace("cache-namespace")
                .build()))
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("..."))),
                // specify the same cache key and paths
                "cache", Map.of(
                        "key", "unique-key",
                        "paths", List.of("/root/cachedir/**/*")))))
        .build();
```

C# / .NET:

```csharp
Bucket sourceBucket;
Bucket myCachingBucket;

new Project(this, "ProjectA", new ProjectProps {
    Source = Source.S3(new S3SourceProps {
        Bucket = sourceBucket,
        Path = "path/to/source-a.zip"
    }),
    // configure the same bucket and path prefix
    Cache = Cache.Bucket(myCachingBucket, new BucketCacheOptions {
        Prefix = "cache",
        // use the same cache namespace
        CacheNamespace = "cache-namespace"
    }),
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "..." }
            } }
        } },
        // specify the same cache key and paths
        { "cache", new Dictionary<string, object> {
            { "key", "unique-key" },
            { "paths", new [] { "/root/cachedir/**/*" } }
        } }
    })
});

new Project(this, "ProjectB", new ProjectProps {
    Source = Source.S3(new S3SourceProps {
        Bucket = sourceBucket,
        Path = "path/to/source-b.zip"
    }),
    // configure the same bucket and path prefix
    Cache = Cache.Bucket(myCachingBucket, new BucketCacheOptions {
        Prefix = "cache",
        // use the same cache namespace
        CacheNamespace = "cache-namespace"
    }),
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "..." }
            } }
        } },
        // specify the same cache key and paths
        { "cache", new Dictionary<string, object> {
            { "key", "unique-key" },
            { "paths", new [] { "/root/cachedir/**/*" } }
        } }
    })
});
```

Golang:

```go
var sourceBucket Bucket
var myCachingBucket Bucket

codebuild.NewProject(this, jsii.String("ProjectA"), &ProjectProps{
	Source: codebuild.Source_S3(&S3SourceProps{
		Bucket: sourceBucket,
		Path: jsii.String("path/to/source-a.zip"),
	}),
	// configure the same bucket and path prefix
	Cache: codebuild.Cache_Bucket(myCachingBucket, &BucketCacheOptions{
		Prefix: jsii.String("cache"),
		// use the same cache namespace
		CacheNamespace: jsii.String("cache-namespace"),
	}),
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("..."),
				},
			},
		},
		// specify the same cache key and paths
		"cache": map[string]interface{}{
			"key": jsii.String("unique-key"),
			"paths": []*string{
				jsii.String("/root/cachedir/**/*"),
			},
		},
	}),
})

codebuild.NewProject(this, jsii.String("ProjectB"), &ProjectProps{
	Source: codebuild.Source_*S3(&S3SourceProps{
		Bucket: sourceBucket,
		Path: jsii.String("path/to/source-b.zip"),
	}),
	// configure the same bucket and path prefix
	Cache: codebuild.Cache_*Bucket(myCachingBucket, &BucketCacheOptions{
		Prefix: jsii.String("cache"),
		// use the same cache namespace
		CacheNamespace: jsii.String("cache-namespace"),
	}),
	BuildSpec: codebuild.BuildSpec_*FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("..."),
				},
			},
		},
		// specify the same cache key and paths
		"cache": map[string]interface{}{
			"key": jsii.String("unique-key"),
			"paths": []*string{
				jsii.String("/root/cachedir/**/*"),
			},
		},
	}),
})
```

### Local Caching

With local caching, the cache is stored on the codebuild instance itself. This
is simple, cheap and fast, but CodeBuild cannot guarantee a reuse of instance
and hence cannot guarantee cache hits. For example, when a build starts and
caches files locally, if two subsequent builds start at the same time afterwards
only one of those builds would get the cache. Three different cache modes are
supported, which can be turned on individually.

* `LocalCacheMode.SOURCE` caches Git metadata for primary and secondary sources.
* `LocalCacheMode.DOCKER_LAYER` caches existing Docker layers.
* `LocalCacheMode.CUSTOM` caches directories you specify in the buildspec file.

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  source: codebuild.Source.gitHubEnterprise({
    httpsCloneUrl: 'https://my-github-enterprise.com/owner/repo',
  }),

  // Enable Docker AND custom caching
  cache: codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER, codebuild.LocalCacheMode.CUSTOM),

  // BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can
  // also come from 'buildspec.yml' in your source.
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: ['...'],
      },
    },
    cache: {
      paths: [
        // The '**/*' is required to indicate all files in this directory
        '/root/cachedir/**/*',
      ],
    },
  }),
});
```

Python:

```python
codebuild.Project(self, "Project",
    source=codebuild.Source.git_hub_enterprise(
        https_clone_url="https://my-github-enterprise.com/owner/repo"
    ),

    # Enable Docker AND custom caching
    cache=codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER, codebuild.LocalCacheMode.CUSTOM),

    # BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can
    # also come from 'buildspec.yml' in your source.
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["..."]
            }
        },
        "cache": {
            "paths": ["/root/cachedir/**/*"
            ]
        }
    })
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .source(Source.gitHubEnterprise(GitHubEnterpriseSourceProps.builder()
                .httpsCloneUrl("https://my-github-enterprise.com/owner/repo")
                .build()))

        // Enable Docker AND custom caching
        .cache(Cache.local(LocalCacheMode.DOCKER_LAYER, LocalCacheMode.CUSTOM))

        // BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can
        // also come from 'buildspec.yml' in your source.
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("..."))),
                "cache", Map.of(
                        "paths", List.of("/root/cachedir/**/*")))))
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Source = Source.GitHubEnterprise(new GitHubEnterpriseSourceProps {
        HttpsCloneUrl = "https://my-github-enterprise.com/owner/repo"
    }),

    // Enable Docker AND custom caching
    Cache = Cache.Local(LocalCacheMode.DOCKER_LAYER, LocalCacheMode.CUSTOM),

    // BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can
    // also come from 'buildspec.yml' in your source.
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "..." }
            } }
        } },
        { "cache", new Dictionary<string, string[]> {
            { "paths", new [] { "/root/cachedir/**/*" } }
        } }
    })
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Source: codebuild.Source_GitHubEnterprise(&GitHubEnterpriseSourceProps{
		HttpsCloneUrl: jsii.String("https://my-github-enterprise.com/owner/repo"),
	}),

	// Enable Docker AND custom caching
	Cache: codebuild.Cache_Local(codebuild.LocalCacheMode_DOCKER_LAYER, codebuild.LocalCacheMode_CUSTOM),

	// BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can
	// also come from 'buildspec.yml' in your source.
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("..."),
				},
			},
		},
		"cache": map[string][]*string{
			"paths": []*string{
				jsii.String("/root/cachedir/**/*"),
			},
		},
	}),
})
```

## Environment

By default, projects use a small instance with an Ubuntu 18.04 image. You
can use the `environment` property to customize the build environment:

* `buildImage` defines the Docker image used. See [Images](#images) below for
  details on how to define build images.
* `certificate` defines the location of a PEM encoded certificate to import.
* `computeType` defines the instance type used for the build.
* `dockerServer` defines the docker server used for the build.
* `hostKernel` defines the host operating system kernel used for the build. See
  [Host kernel](#host-kernel) below.
* `privileged` can be set to `true` to allow privileged access.
* `environmentVariables` can be set at this level (and also at the project
  level).

Finally, you can also set the build environment `fleet` property to create
a reserved capacity project. See [Fleet](#fleet) for more information.

### Host kernel

CodeBuild runs your build container on a host instance. You can select which host
operating system kernel that instance uses with the `hostKernel` property:

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
    hostKernel: codebuild.HostKernel.LINUX_KERNEL_6,
  },
});
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0,
        host_kernel=codebuild.HostKernel.LINUX_KERNEL_6
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .hostKernel(HostKernel.LINUX_KERNEL_6)
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxBuildImage.STANDARD_7_0,
        HostKernel = HostKernel.LINUX_KERNEL_6
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
		HostKernel: codebuild.HostKernel_LINUX_KERNEL_6,
	},
})
```

The host kernel does not affect the build environment operating system, which is
determined by the `buildImage`. Use `HostKernel.LINUX_KERNEL_LATEST` to always run
on the latest supported host kernel.

This setting only applies to the `LINUX_CONTAINER`, `ARM_CONTAINER`, `LINUX_EC2` and
`ARM_EC2` environment types. Specifying it with a Windows, Lambda or Mac build image
results in a validation error at synthesis time.

## Images

The CodeBuild library supports Linux, Windows, and Mac images via the
[`LinuxBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxBuildImage.html) (or [`LinuxArmBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmBuildImage.html)), [`WindowsBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsBuildImage.html), and [`MacBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.MacBuildImage.html) classes, respectively.
With the introduction of Lambda compute support, the `LinuxLambdaBuildImage ` (or [`LinuxArmLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmLambdaBuildImage.html)) class
is available for specifying Lambda-compatible images.

You can specify one of the predefined Windows/Linux images by using one
of the constants such as `WindowsBuildImage.WIN_SERVER_CORE_2019_BASE`,
`WindowsBuildImage.WINDOWS_BASE_2_0`, `LinuxBuildImage.STANDARD_2_0`,
`LinuxBuildImage.AMAZON_LINUX_2_5`, `LinuxBuildImage.AMAZON_LINUX_2023_6`, `LinuxBuildImage.STANDARD_7_0`, `LinuxBuildImage.STANDARD_8_0`, `MacBuildImage.BASE_14`, `MacBuildImage.BASE_15`, `MacBuildImage.BASE_26`, `LinuxArmBuildImage.AMAZON_LINUX_2_ARM`, `LinuxArmBuildImage.AMAZON_LINUX_2023_STANDARD_4_0`,
`LinuxLambdaBuildImage.AMAZON_LINUX_2_NODE_18`, `LinuxLambdaBuildImage.AMAZON_LINUX_2023_NODE_24`, `LinuxArmLambdaBuildImage.AMAZON_LINUX_2_NODE_18` or `LinuxArmLambdaBuildImage.AMAZON_LINUX_2023_NODE_24`.

Alternatively, you can specify a custom image using one of the static methods on
[`LinuxBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxBuildImage.html):

* `LinuxBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }])` to reference an image in any public or private Docker registry.
* `LinuxBuildImage.fromEcrRepository(repo[, tag])` to reference an image available in an
  ECR repository.
* `LinuxBuildImage.fromAsset(parent, id, props)` to use an image created from a
  local asset.
* `LinuxBuildImage.fromCodeBuildImageId(id)` to reference a pre-defined, CodeBuild-provided Docker image.

or one of the corresponding methods on [`WindowsBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsBuildImage.html):

* `WindowsBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }, imageType])`
* `WindowsBuildImage.fromEcrRepository(repo[, tag, imageType])`
* `WindowsBuildImage.fromAsset(parent, id, props, [, imageType])`

or one of the corresponding methods on [`MacBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.MacBuildImage.html):

* `MacBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }, imageType])`
* `MacBuildImage.fromEcrRepository(repo[, tag, imageType])`
* `MacBuildImage.fromAsset(parent, id, props, [, imageType])`

or one of the corresponding methods on [`LinuxArmBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmBuildImage.html):

* `LinuxArmBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }])`
* `LinuxArmBuildImage.fromEcrRepository(repo[, tag])`

**Note:** You cannot specify custom images on [`LinuxLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxLambdaBuildImage.html) or [`LinuxArmLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmLambdaBuildImage.html) images.

Note that the [`WindowsBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsBuildImage.html) version of the static methods accepts an optional parameter of type [`WindowsImageType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsImageType.html),
which can be either `WindowsImageType.STANDARD`, the default, or `WindowsImageType.SERVER_2019`:

TypeScript:

```ts
declare const ecrRepository: ecr.Repository;

new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.WindowsBuildImage.fromEcrRepository(ecrRepository, 'v1.0', codebuild.WindowsImageType.SERVER_2019),
    // optional certificate to include in the build image
    certificate: {
      bucket: s3.Bucket.fromBucketName(this, 'Bucket', 'amzn-s3-demo-bucket'),
      objectKey: 'path/to/cert.pem',
    },
  },
  // ...
})
```

Python:

```python
# ecr_repository: ecr.Repository

codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.WindowsBuildImage.from_ecr_repository(ecr_repository, "v1.0", codebuild.WindowsImageType.SERVER_2019),
        # optional certificate to include in the build image
        certificate=codebuild.BuildEnvironmentCertificate(
            bucket=s3.Bucket.from_bucket_name(self, "Bucket", "amzn-s3-demo-bucket"),
            object_key="path/to/cert.pem"
        )
    )
)
```

Java:

```java
Repository ecrRepository;

Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(WindowsBuildImage.fromEcrRepository(ecrRepository, "v1.0", WindowsImageType.SERVER_2019))
                // optional certificate to include in the build image
                .certificate(BuildEnvironmentCertificate.builder()
                        .bucket(Bucket.fromBucketName(this, "Bucket", "amzn-s3-demo-bucket"))
                        .objectKey("path/to/cert.pem")
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
Repository ecrRepository;

new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = WindowsBuildImage.FromEcrRepository(ecrRepository, "v1.0", WindowsImageType.SERVER_2019),
        // optional certificate to include in the build image
        Certificate = new BuildEnvironmentCertificate {
            Bucket = Bucket.FromBucketName(this, "Bucket", "amzn-s3-demo-bucket"),
            ObjectKey = "path/to/cert.pem"
        }
    }
});
```

Golang:

```go
var ecrRepository Repository

codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.WindowsBuildImage_FromEcrRepository(ecrRepository, jsii.String("v1.0"), codebuild.WindowsImageType_SERVER_2019),
		// optional certificate to include in the build image
		Certificate: &BuildEnvironmentCertificate{
			Bucket: s3.Bucket_FromBucketName(this, jsii.String("Bucket"), jsii.String("amzn-s3-demo-bucket")),
			ObjectKey: jsii.String("path/to/cert.pem"),
		},
	},
})
```

The following example shows how to define an image from a Docker asset:

TypeScript:

```ts
environment: {
  buildImage: codebuild.LinuxBuildImage.fromAsset(this, 'MyImage', {
    directory: path.join(__dirname, 'demo-image'),
  }),
},
```

Python:

```python
environment=cdk.aws_codebuild.BuildEnvironment(
    build_image=codebuild.LinuxBuildImage.from_asset(self, "MyImage",
        directory=path.join(__dirname, "demo-image")
    )
)
```

Java:

```java
.environment(BuildEnvironment.builder()
        .buildImage(LinuxBuildImage.fromAsset(this, "MyImage", DockerImageAssetProps.builder()
                .directory(join(__dirname, "demo-image"))
                .build()))
        .build())
.build();
```

C# / .NET:

```csharp
Environment = new BuildEnvironment {
    BuildImage = LinuxBuildImage.FromAsset(this, "MyImage", new DockerImageAssetProps {
        Directory = Join(__dirname, "demo-image")
    })
}
```

Golang:

```go
Environment: &BuildEnvironment{
	BuildImage: codebuild.LinuxBuildImage_FromAsset(this, jsii.String("MyImage"), &DockerImageAssetProps{
		Directory: path.join(__dirname, jsii.String("demo-image")),
	}),
},
```

The following example shows how to define an image from an ECR repository:

TypeScript:

```ts
environment: {
  buildImage: codebuild.LinuxBuildImage.fromEcrRepository(ecrRepository, 'v1.0'),
},
```

Python:

```python
environment=cdk.aws_codebuild.BuildEnvironment(
    build_image=codebuild.LinuxBuildImage.from_ecr_repository(ecr_repository, "v1.0")
)
```

Java:

```java
.environment(BuildEnvironment.builder()
        .buildImage(LinuxBuildImage.fromEcrRepository(ecrRepository, "v1.0"))
        .build())
.build();
```

C# / .NET:

```csharp
Environment = new BuildEnvironment {
    BuildImage = LinuxBuildImage.FromEcrRepository(ecrRepository, "v1.0")
}
```

Golang:

```go
Environment: &BuildEnvironment{
	BuildImage: codebuild.LinuxBuildImage_FromEcrRepository(ecrRepository, jsii.String("v1.0")),
},
```

The following example shows how to define an image from a private docker registry:

TypeScript:

```ts
environment: {
  buildImage: codebuild.LinuxBuildImage.fromDockerRegistry('my-registry/my-repo', {
    secretsManagerCredentials: secrets,
  }),
},
```

Python:

```python
environment=cdk.aws_codebuild.BuildEnvironment(
    build_image=codebuild.LinuxBuildImage.from_docker_registry("my-registry/my-repo",
        secrets_manager_credentials=secrets
    )
)
```

Java:

```java
.environment(BuildEnvironment.builder()
        .buildImage(LinuxBuildImage.fromDockerRegistry("my-registry/my-repo", DockerImageOptions.builder()
                .secretsManagerCredentials(secrets)
                .build()))
        .build())
.build();
```

C# / .NET:

```csharp
Environment = new BuildEnvironment {
    BuildImage = LinuxBuildImage.FromDockerRegistry("my-registry/my-repo", new DockerImageOptions {
        SecretsManagerCredentials = secrets
    })
}
```

Golang:

```go
Environment: &BuildEnvironment{
	BuildImage: codebuild.LinuxBuildImage_FromDockerRegistry(jsii.String("my-registry/my-repo"), &DockerImageOptions{
		SecretsManagerCredentials: secrets,
	}),
},
```

### GPU images

The class [`LinuxGpuBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxGpuBuildImage.html) contains constants for working with
[AWS Deep Learning Container images](https://aws.amazon.com/releasenotes/available-deep-learning-containers-images):

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxGpuBuildImage.DLC_TENSORFLOW_2_1_0_INFERENCE,
  },
  // ...
})
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxGpuBuildImage.DLC_TENSORFLOW_2_1_0_INFERENCE
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxGpuBuildImage.DLC_TENSORFLOW_2_1_0_INFERENCE)
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxGpuBuildImage.DLC_TENSORFLOW_2_1_0_INFERENCE
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxGpuBuildImage_DLC_TENSORFLOW_2_1_0_INFERENCE(),
	},
})
```

One complication is that the repositories for the DLC images are in
different accounts in different AWS regions.
In most cases, the CDK will handle providing the correct account for you;
in rare cases (for example, deploying to new regions)
where our information might be out of date,
you can always specify the account
(along with the repository name and tag)
explicitly using the `awsDeepLearningContainersImage` method:

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxGpuBuildImage.awsDeepLearningContainersImage(
      'tensorflow-inference', '2.1.0-gpu-py36-cu101-ubuntu18.04', '123456789012'),
  },
  // ...
})
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxGpuBuildImage.aws_deep_learning_containers_image("tensorflow-inference", "2.1.0-gpu-py36-cu101-ubuntu18.04", "123456789012")
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxGpuBuildImage.awsDeepLearningContainersImage("tensorflow-inference", "2.1.0-gpu-py36-cu101-ubuntu18.04", "123456789012"))
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxGpuBuildImage.AwsDeepLearningContainersImage("tensorflow-inference", "2.1.0-gpu-py36-cu101-ubuntu18.04", "123456789012")
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxGpuBuildImage_AwsDeepLearningContainersImage(jsii.String("tensorflow-inference"), jsii.String("2.1.0-gpu-py36-cu101-ubuntu18.04"), jsii.String("123456789012")),
	},
})
```

Alternatively, you can reference an image available in an ECR repository using the `LinuxGpuBuildImage.fromEcrRepository(repo[, tag])` method.

### Lambda images

The [`LinuxLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxLambdaBuildImage.html) (or [`LinuxArmLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmLambdaBuildImage.html)) class contains constants for working with
Lambda compute:

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxLambdaBuildImage.AMAZON_LINUX_2_NODE_18,
  },
  // ...
})
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxLambdaBuildImage.AMAZON_LINUX_2_NODE_18
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxLambdaBuildImage.AMAZON_LINUX_2_NODE_18)
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxLambdaBuildImage.AMAZON_LINUX_2_NODE_18
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxLambdaBuildImage_AMAZON_LINUX_2_NODE_18(),
	},
})
```

> Visit [AWS Lambda compute in AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/lambda.html) for more details.

## Fleet

By default, a CodeBuild project will request on-demand compute resources
to process your build requests. While being able to scale and handle high load,
on-demand resources can also be slow to provision.

Reserved capacity fleets are an alternative to on-demand.
Dedicated instances, maintained by CodeBuild,
will be ready to fulfill your build requests immediately.
Skipping the provisioning step in your project will reduce your build time,
at the cost of paying for these reserved instances, even when idling, until they are released.

For more information, see [Working with reserved capacity in AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/fleets.html) in the CodeBuild documentation.

TypeScript:

```ts
const fleet = new codebuild.Fleet(this, 'Fleet', {
    computeType: codebuild.FleetComputeType.MEDIUM,
    environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
    baseCapacity: 1,
});

new codebuild.Project(this, 'Project', {
  environment: {
    fleet,
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
  },
  // ...
})
```

Python:

```python
fleet = codebuild.Fleet(self, "Fleet",
    compute_type=codebuild.FleetComputeType.MEDIUM,
    environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
    base_capacity=1
)

codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        fleet=fleet,
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0
    )
)
```

Java:

```java
Fleet fleet = Fleet.Builder.create(this, "Fleet")
        .computeType(FleetComputeType.MEDIUM)
        .environmentType(EnvironmentType.LINUX_CONTAINER)
        .baseCapacity(1)
        .build();

Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .fleet(fleet)
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .build())
        .build();
```

C# / .NET:

```csharp
var fleet = new Fleet(this, "Fleet", new FleetProps {
    ComputeType = FleetComputeType.MEDIUM,
    EnvironmentType = EnvironmentType.LINUX_CONTAINER,
    BaseCapacity = 1
});

new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        Fleet = fleet,
        BuildImage = LinuxBuildImage.STANDARD_7_0
    }
});
```

Golang:

```go
fleet := codebuild.NewFleet(this, jsii.String("Fleet"), &FleetProps{
	ComputeType: codebuild.FleetComputeType_MEDIUM,
	EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
	BaseCapacity: jsii.Number(1),
})

codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		Fleet: *Fleet,
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
	},
})
```

You can also import an existing fleet to share its resources
among several projects across multiple stacks:

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    fleet: codebuild.Fleet.fromFleetArn(
      this, 'SharedFleet',
      'arn:aws:codebuild:us-east-1:123456789012:fleet/MyFleet:ed0d0823-e38a-4c10-90a1-1bf25f50fa76',
    ),
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
  },
  // ...
})
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        fleet=codebuild.Fleet.from_fleet_arn(self, "SharedFleet", "arn:aws:codebuild:us-east-1:123456789012:fleet/MyFleet:ed0d0823-e38a-4c10-90a1-1bf25f50fa76"),
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .fleet(Fleet.fromFleetArn(this, "SharedFleet", "arn:aws:codebuild:us-east-1:123456789012:fleet/MyFleet:ed0d0823-e38a-4c10-90a1-1bf25f50fa76"))
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        Fleet = Fleet.FromFleetArn(this, "SharedFleet", "arn:aws:codebuild:us-east-1:123456789012:fleet/MyFleet:ed0d0823-e38a-4c10-90a1-1bf25f50fa76"),
        BuildImage = LinuxBuildImage.STANDARD_7_0
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		Fleet: codebuild.Fleet_FromFleetArn(this, jsii.String("SharedFleet"), jsii.String("arn:aws:codebuild:us-east-1:123456789012:fleet/MyFleet:ed0d0823-e38a-4c10-90a1-1bf25f50fa76")),
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
	},
})
```

### Attribute-based compute

You can use [attribute-based compute](https://docs.aws.amazon.com/codebuild/latest/userguide/fleets.html#fleets.attribute-compute) for your fleet by setting the `computeType` to `ATTRIBUTE_BASED`.
This allows you to specify the attributes in `computeConfiguration` such as vCPUs, memory, disk space, and the machineType.
After specifying some or all of the available attributes, CodeBuild will select the cheapest compute type from available instance types as that at least matches all given criteria.

TypeScript:

```ts
import { Size } from 'aws-cdk-lib';

const fleet = new codebuild.Fleet(this, 'MyFleet', {
  baseCapacity: 1,
  computeType: codebuild.FleetComputeType.ATTRIBUTE_BASED,
  environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
  computeConfiguration: {
    vCpu: 2,
    memory: Size.gibibytes(4),
    disk: Size.gibibytes(10),
    machineType: codebuild.MachineType.GENERAL,
  },
});
```

Python:

```python
from aws_cdk import Size

fleet = codebuild.Fleet(self, "MyFleet",
    base_capacity=1,
    compute_type=codebuild.FleetComputeType.ATTRIBUTE_BASED,
    environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
    compute_configuration=codebuild.ComputeConfiguration(
        v_cpu=2,
        memory=Size.gibibytes(4),
        disk=Size.gibibytes(10),
        machine_type=codebuild.MachineType.GENERAL
    )
)
```

Java:

```java
import software.amazon.awscdk.Size;

Fleet fleet = Fleet.Builder.create(this, "MyFleet")
        .baseCapacity(1)
        .computeType(FleetComputeType.ATTRIBUTE_BASED)
        .environmentType(EnvironmentType.LINUX_CONTAINER)
        .computeConfiguration(ComputeConfiguration.builder()
                .vCpu(2)
                .memory(Size.gibibytes(4))
                .disk(Size.gibibytes(10))
                .machineType(MachineType.GENERAL)
                .build())
        .build();
```

C# / .NET:

```csharp
using Amazon.CDK;

var fleet = new Fleet(this, "MyFleet", new FleetProps {
    BaseCapacity = 1,
    ComputeType = FleetComputeType.ATTRIBUTE_BASED,
    EnvironmentType = EnvironmentType.LINUX_CONTAINER,
    ComputeConfiguration = new ComputeConfiguration {
        VCpu = 2,
        Memory = Size.Gibibytes(4),
        Disk = Size.Gibibytes(10),
        MachineType = MachineType.GENERAL
    }
});
```

Golang:

```go
import "github.com/aws/aws-cdk-go/awscdk"

fleet := codebuild.NewFleet(this, jsii.String("MyFleet"), &FleetProps{
	BaseCapacity: jsii.Number(1),
	ComputeType: codebuild.FleetComputeType_ATTRIBUTE_BASED,
	EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
	ComputeConfiguration: &ComputeConfiguration{
		VCpu: jsii.Number(2),
		Memory: awscdk.Size_Gibibytes(jsii.Number(4)),
		Disk: awscdk.Size_*Gibibytes(jsii.Number(10)),
		MachineType: codebuild.MachineType_GENERAL,
	},
})
```

### Custom instance types
You can use [specific EC2 instance
types](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.instance-types)
for your fleet by setting the `computeType` to `CUSTOM_INSTANCE_TYPE`.  This
allows you to specify the `instanceType` in `computeConfiguration`. Only certain
EC2 instance types are supported; see the linked documentation for details.

TypeScript:

```ts
import { Size } from 'aws-cdk-lib';

const fleet = new codebuild.Fleet(this, 'MyFleet', {
  baseCapacity: 1,
  computeType: codebuild.FleetComputeType.CUSTOM_INSTANCE_TYPE,
  environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
  computeConfiguration: {
    instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
    // By default, 64 GiB of disk space is included. Any value optionally
    // specified here is _incremental_ on top of the included disk space.
    disk: Size.gibibytes(10),
  },
});
```

Python:

```python
from aws_cdk import Size

fleet = codebuild.Fleet(self, "MyFleet",
    base_capacity=1,
    compute_type=codebuild.FleetComputeType.CUSTOM_INSTANCE_TYPE,
    environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
    compute_configuration=codebuild.ComputeConfiguration(
        instance_type=ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
        # By default, 64 GiB of disk space is included. Any value optionally
        # specified here is _incremental_ on top of the included disk space.
        disk=Size.gibibytes(10)
    )
)
```

Java:

```java
import software.amazon.awscdk.Size;

Fleet fleet = Fleet.Builder.create(this, "MyFleet")
        .baseCapacity(1)
        .computeType(FleetComputeType.CUSTOM_INSTANCE_TYPE)
        .environmentType(EnvironmentType.LINUX_CONTAINER)
        .computeConfiguration(ComputeConfiguration.builder()
                .instanceType(InstanceType.of(InstanceClass.T3, InstanceSize.MEDIUM))
                // By default, 64 GiB of disk space is included. Any value optionally
                // specified here is _incremental_ on top of the included disk space.
                .disk(Size.gibibytes(10))
                .build())
        .build();
```

C# / .NET:

```csharp
using Amazon.CDK;

var fleet = new Fleet(this, "MyFleet", new FleetProps {
    BaseCapacity = 1,
    ComputeType = FleetComputeType.CUSTOM_INSTANCE_TYPE,
    EnvironmentType = EnvironmentType.LINUX_CONTAINER,
    ComputeConfiguration = new ComputeConfiguration {
        InstanceType = InstanceType.Of(InstanceClass.T3, InstanceSize.MEDIUM),
        // By default, 64 GiB of disk space is included. Any value optionally
        // specified here is _incremental_ on top of the included disk space.
        Disk = Size.Gibibytes(10)
    }
});
```

Golang:

```go
import "github.com/aws/aws-cdk-go/awscdk"

fleet := codebuild.NewFleet(this, jsii.String("MyFleet"), &FleetProps{
	BaseCapacity: jsii.Number(1),
	ComputeType: codebuild.FleetComputeType_CUSTOM_INSTANCE_TYPE,
	EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
	ComputeConfiguration: &ComputeConfiguration{
		InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_T3, ec2.InstanceSize_MEDIUM),
		// By default, 64 GiB of disk space is included. Any value optionally
		// specified here is _incremental_ on top of the included disk space.
		Disk: awscdk.Size_Gibibytes(jsii.Number(10)),
	},
})
```

### Fleet overflow behavior

When your builds exceed the capacity of your fleet, you can specify how CodeBuild should handle the overflow builds by setting the `overflowBehavior` property:

TypeScript:

```ts
const fleet = new codebuild.Fleet(this, 'Fleet', {
  computeType: codebuild.FleetComputeType.MEDIUM,
  environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
  baseCapacity: 1,
  overflowBehavior: codebuild.FleetOverflowBehavior.ON_DEMAND,
});
```

Python:

```python
fleet = codebuild.Fleet(self, "Fleet",
    compute_type=codebuild.FleetComputeType.MEDIUM,
    environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
    base_capacity=1,
    overflow_behavior=codebuild.FleetOverflowBehavior.ON_DEMAND
)
```

Java:

```java
Fleet fleet = Fleet.Builder.create(this, "Fleet")
        .computeType(FleetComputeType.MEDIUM)
        .environmentType(EnvironmentType.LINUX_CONTAINER)
        .baseCapacity(1)
        .overflowBehavior(FleetOverflowBehavior.ON_DEMAND)
        .build();
```

C# / .NET:

```csharp
var fleet = new Fleet(this, "Fleet", new FleetProps {
    ComputeType = FleetComputeType.MEDIUM,
    EnvironmentType = EnvironmentType.LINUX_CONTAINER,
    BaseCapacity = 1,
    OverflowBehavior = FleetOverflowBehavior.ON_DEMAND
});
```

Golang:

```go
fleet := codebuild.NewFleet(this, jsii.String("Fleet"), &FleetProps{
	ComputeType: codebuild.FleetComputeType_MEDIUM,
	EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
	BaseCapacity: jsii.Number(1),
	OverflowBehavior: codebuild.FleetOverflowBehavior_ON_DEMAND,
})
```

The available overflow behaviors are:

- `QUEUE` (default): Overflow builds wait for existing fleet instances to become available
- `ON_DEMAND`: Overflow builds run on CodeBuild on-demand instances

Note: If you set overflow behavior to `ON_DEMAND` for a VPC-connected fleet, ensure your VPC settings allow access to public AWS services.

### VPCs
The same considerations that apply to [Project
VPCs](#definition-of-vpc-configuration-in-codebuild-project) also apply to Fleet
VPCs.  When using a Fleet in a CodeBuild Project, it is an error to configure a
VPC on the Project. Configure a VPC on the fleet instead.

TypeScript:

```ts
declare const loadBalancer: elbv2.ApplicationLoadBalancer;

const vpc = new ec2.Vpc(this, 'MyVPC');
const fleet = new codebuild.Fleet(this, 'MyProject', {
  computeType: codebuild.FleetComputeType.MEDIUM,
  environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
  baseCapacity: 1,
  vpc,
});

fleet.connections.allowTo(loadBalancer, ec2.Port.tcp(443));

const project = new codebuild.Project(this, 'MyProject', {
  environment: {
    fleet,
  },
  buildSpec: codebuild.BuildSpec.fromObject({
    // ...
  }),
  // Trying to configure a project-level VPC is an error, because this project
  // runs on the Fleet created above.
  // vpc,
});
```

Python:

```python
# load_balancer: elbv2.ApplicationLoadBalancer

vpc = ec2.Vpc(self, "MyVPC")
fleet = codebuild.Fleet(self, "MyProject",
    compute_type=codebuild.FleetComputeType.MEDIUM,
    environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
    base_capacity=1,
    vpc=vpc
)

fleet.connections.allow_to(load_balancer, ec2.Port.tcp(443))

project = codebuild.Project(self, "MyProject",
    environment=codebuild.BuildEnvironment(
        fleet=fleet
    ),
    build_spec=codebuild.BuildSpec.from_object({})
)
```

Java:

```java
ApplicationLoadBalancer loadBalancer;

Vpc vpc = new Vpc(this, "MyVPC");
Fleet fleet = Fleet.Builder.create(this, "MyProject")
        .computeType(FleetComputeType.MEDIUM)
        .environmentType(EnvironmentType.LINUX_CONTAINER)
        .baseCapacity(1)
        .vpc(vpc)
        .build();

fleet.connections.allowTo(loadBalancer, Port.tcp(443));

Project project = Project.Builder.create(this, "MyProject")
        .environment(BuildEnvironment.builder()
                .fleet(fleet)
                .build())
        .buildSpec(BuildSpec.fromObject(Map.of()))
        .build();
```

C# / .NET:

```csharp
ApplicationLoadBalancer loadBalancer;

var vpc = new Vpc(this, "MyVPC");
var fleet = new Fleet(this, "MyProject", new FleetProps {
    ComputeType = FleetComputeType.MEDIUM,
    EnvironmentType = EnvironmentType.LINUX_CONTAINER,
    BaseCapacity = 1,
    Vpc = vpc
});

fleet.Connections.AllowTo(loadBalancer, Port.Tcp(443));

var project = new Project(this, "MyProject", new ProjectProps {
    Environment = new BuildEnvironment {
        Fleet = fleet
    },
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> { })
});
```

Golang:

```go
var loadBalancer ApplicationLoadBalancer

vpc := ec2.NewVpc(this, jsii.String("MyVPC"))
fleet := codebuild.NewFleet(this, jsii.String("MyProject"), &FleetProps{
	ComputeType: codebuild.FleetComputeType_MEDIUM,
	EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
	BaseCapacity: jsii.Number(1),
	Vpc: Vpc,
})

fleet.connections.AllowTo(loadBalancer, ec2.Port_Tcp(jsii.Number(443)))

project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Environment: &BuildEnvironment{
		Fleet: *Fleet,
	},
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
	}),
})
```

## Logs

CodeBuild lets you specify an S3 Bucket, CloudWatch Log Group or both to receive logs from your projects.

By default, logs will go to cloudwatch.

### CloudWatch Logs Example

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  logging: {
    cloudWatch: {
      logGroup: new logs.LogGroup(this, `MyLogGroup`),
    }
  },
})
```

Python:

```python
codebuild.Project(self, "Project",
    logging=codebuild.LoggingOptions(
        cloud_watch=codebuild.CloudWatchLoggingOptions(
            log_group=logs.LogGroup(self, "MyLogGroup")
        )
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .logging(LoggingOptions.builder()
                .cloudWatch(CloudWatchLoggingOptions.builder()
                        .logGroup(new LogGroup(this, "MyLogGroup"))
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Logging = new LoggingOptions {
        CloudWatch = new CloudWatchLoggingOptions {
            LogGroup = new LogGroup(this, "MyLogGroup")
        }
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Logging: &LoggingOptions{
		CloudWatch: &CloudWatchLoggingOptions{
			LogGroup: logs.NewLogGroup(this, jsii.String("MyLogGroup")),
		},
	},
})
```

### S3 Logs Example

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  logging: {
    s3: {
      bucket: new s3.Bucket(this, `LogBucket`)
    }
  },
})
```

Python:

```python
codebuild.Project(self, "Project",
    logging=codebuild.LoggingOptions(
        s3=codebuild.S3LoggingOptions(
            bucket=s3.Bucket(self, "LogBucket")
        )
    )
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .logging(LoggingOptions.builder()
                .s3(S3LoggingOptions.builder()
                        .bucket(new Bucket(this, "LogBucket"))
                        .build())
                .build())
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Logging = new LoggingOptions {
        S3 = new S3LoggingOptions {
            Bucket = new Bucket(this, "LogBucket")
        }
    }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Logging: &LoggingOptions{
		S3: &S3LoggingOptions{
			Bucket: s3.NewBucket(this, jsii.String("LogBucket")),
		},
	},
})
```

## Debugging builds interactively using SSM Session Manager

Integration with SSM Session Manager makes it possible to add breakpoints to your
build commands, pause the build there and log into the container to interactively
debug the environment.

To do so, you need to:

* Create the build with `ssmSessionPermissions: true`.
* Use a build image with SSM agent installed and configured (default CodeBuild images come with the image preinstalled).
* Start the build with [debugSessionEnabled](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html#CodeBuild-StartBuild-request-debugSessionEnabled) set to true.

If these conditions are met, execution of the command `codebuild-breakpoint`
will suspend your build and allow you to attach a Session Manager session from
the CodeBuild console.

For more information, see [View a running build in Session
Manager](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html)
in the CodeBuild documentation.

Example:

TypeScript:

```ts
new codebuild.Project(this, 'Project', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.STANDARD_7_0,
  },
  ssmSessionPermissions: true,
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: [
          // Pause the build container if possible
          'codebuild-breakpoint',
          // Regular build in a script in the repository
          './my-build.sh',
        ],
      },
    },
  }),
})
```

Python:

```python
codebuild.Project(self, "Project",
    environment=codebuild.BuildEnvironment(
        build_image=codebuild.LinuxBuildImage.STANDARD_7_0
    ),
    ssm_session_permissions=True,
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["codebuild-breakpoint", "./my-build.sh"
                ]
            }
        }
    })
)
```

Java:

```java
Project.Builder.create(this, "Project")
        .environment(BuildEnvironment.builder()
                .buildImage(LinuxBuildImage.STANDARD_7_0)
                .build())
        .ssmSessionPermissions(true)
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("codebuild-breakpoint", "./my-build.sh"))))))
        .build();
```

C# / .NET:

```csharp
new Project(this, "Project", new ProjectProps {
    Environment = new BuildEnvironment {
        BuildImage = LinuxBuildImage.STANDARD_7_0
    },
    SsmSessionPermissions = true,
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "codebuild-breakpoint", "./my-build.sh" }
            } }
        } }
    })
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Environment: &BuildEnvironment{
		BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
	},
	SsmSessionPermissions: jsii.Boolean(true),
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("codebuild-breakpoint"),
					jsii.String("./my-build.sh"),
				},
			},
		},
	}),
})
```

## Credentials

CodeBuild allows you to store credentials used when communicating with various sources,
like GitHub:

TypeScript:

```ts
new codebuild.GitHubSourceCredentials(this, 'CodeBuildGitHubCreds', {
  accessToken: SecretValue.secretsManager('my-token'),
});
// GitHub Enterprise is almost the same,
// except the class is called GitHubEnterpriseSourceCredentials
```

Python:

```python
codebuild.GitHubSourceCredentials(self, "CodeBuildGitHubCreds",
    access_token=SecretValue.secrets_manager("my-token")
)
```

Java:

```java
GitHubSourceCredentials.Builder.create(this, "CodeBuildGitHubCreds")
        .accessToken(SecretValue.secretsManager("my-token"))
        .build();
```

C# / .NET:

```csharp
new GitHubSourceCredentials(this, "CodeBuildGitHubCreds", new GitHubSourceCredentialsProps {
    AccessToken = SecretValue.SecretsManager("my-token")
});
```

Golang:

```go
codebuild.NewGitHubSourceCredentials(this, jsii.String("CodeBuildGitHubCreds"), &GitHubSourceCredentialsProps{
	AccessToken: awscdk.SecretValue_SecretsManager(jsii.String("my-token")),
})
```

and BitBucket:

TypeScript:

```ts
new codebuild.BitBucketSourceCredentials(this, 'CodeBuildBitBucketCreds', {
  username: SecretValue.secretsManager('my-bitbucket-creds', { jsonField: 'username' }),
  password: SecretValue.secretsManager('my-bitbucket-creds', { jsonField: 'password' }),
});
```

Python:

```python
codebuild.BitBucketSourceCredentials(self, "CodeBuildBitBucketCreds",
    username=SecretValue.secrets_manager("my-bitbucket-creds", json_field="username"),
    password=SecretValue.secrets_manager("my-bitbucket-creds", json_field="password")
)
```

Java:

```java
BitBucketSourceCredentials.Builder.create(this, "CodeBuildBitBucketCreds")
        .username(SecretValue.secretsManager("my-bitbucket-creds", SecretsManagerSecretOptions.builder().jsonField("username").build()))
        .password(SecretValue.secretsManager("my-bitbucket-creds", SecretsManagerSecretOptions.builder().jsonField("password").build()))
        .build();
```

C# / .NET:

```csharp
new BitBucketSourceCredentials(this, "CodeBuildBitBucketCreds", new BitBucketSourceCredentialsProps {
    Username = SecretValue.SecretsManager("my-bitbucket-creds", new SecretsManagerSecretOptions { JsonField = "username" }),
    Password = SecretValue.SecretsManager("my-bitbucket-creds", new SecretsManagerSecretOptions { JsonField = "password" })
});
```

Golang:

```go
codebuild.NewBitBucketSourceCredentials(this, jsii.String("CodeBuildBitBucketCreds"), &BitBucketSourceCredentialsProps{
	Username: awscdk.SecretValue_SecretsManager(jsii.String("my-bitbucket-creds"), &SecretsManagerSecretOptions{
		JsonField: jsii.String("username"),
	}),
	Password: awscdk.SecretValue_*SecretsManager(jsii.String("my-bitbucket-creds"), &SecretsManagerSecretOptions{
		JsonField: jsii.String("password"),
	}),
})
```

**Note**: the credentials are global to a given account in a given region -
they are not defined per CodeBuild project.
CodeBuild only allows storing a single credential of a given type
(GitHub, GitHub Enterprise or BitBucket)
in a given account in a given region -
any attempt to save more than one will result in an error.
You can use the [`list-source-credentials` AWS CLI operation](https://docs.aws.amazon.com/cli/latest/reference/codebuild/list-source-credentials.html)
to inspect what credentials are stored in your account.

## Test reports

You can specify a test report in your buildspec:

TypeScript:

```ts
const project = new codebuild.Project(this, 'Project', {
  buildSpec: codebuild.BuildSpec.fromObject({
    // ...
    reports: {
      myReport: {
        files: '**/*',
        'base-directory': 'build/test-results',
      },
    },
  }),
});
```

Python:

```python
project = codebuild.Project(self, "Project",
    build_spec=codebuild.BuildSpec.from_object({
        # ...
        "reports": {
            "my_report": {
                "files": "**/*",
                "base-directory": "build/test-results"
            }
        }
    })
)
```

Java:

```java
Project project = Project.Builder.create(this, "Project")
        .buildSpec(BuildSpec.fromObject(Map.of(
                // ...
                "reports", Map.of(
                        "myReport", Map.of(
                                "files", "**/*",
                                "base-directory", "build/test-results")))))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "Project", new ProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        // ...
        { "reports", new Dictionary<string, IDictionary<string, string>> {
            { "myReport", new Struct {
                Files = "**/*",
                Base-directory = "build/test-results"
            } }
        } }
    })
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		// ...
		"reports": map[string]map[string]*string{
			"myReport": map[string]*string{
				"files": jsii.String("**/*"),
				"base-directory": jsii.String("build/test-results"),
			},
		},
	}),
})
```

This will create a new test report group,
with the name `<ProjectName>-myReport`.

The project's role in the CDK will always be granted permissions to create and use report groups
with names starting with the project's name;
if you'd rather not have those permissions added,
you can opt out of it when creating the project:

TypeScript:

```ts
declare const source: codebuild.Source;

const project = new codebuild.Project(this, 'Project', {
  source,
  grantReportGroupPermissions: false,
});
```

Python:

```python
# source: codebuild.Source

project = codebuild.Project(self, "Project",
    source=source,
    grant_report_group_permissions=False
)
```

Java:

```java
Source source;

Project project = Project.Builder.create(this, "Project")
        .source(source)
        .grantReportGroupPermissions(false)
        .build();
```

C# / .NET:

```csharp
Source source;

var project = new Project(this, "Project", new ProjectProps {
    Source = source,
    GrantReportGroupPermissions = false
});
```

Golang:

```go
var source Source

project := codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Source: Source,
	GrantReportGroupPermissions: jsii.Boolean(false),
})
```

Alternatively, you can specify an ARN of an existing resource group,
instead of a simple name, in your buildspec:

TypeScript:

```ts
declare const source: codebuild.Source;

// create a new ReportGroup
const reportGroup = new codebuild.ReportGroup(this, 'ReportGroup');

const project = new codebuild.Project(this, 'Project', {
  source,
  buildSpec: codebuild.BuildSpec.fromObject({
    // ...
    reports: {
      [reportGroup.reportGroupArn]: {
        files: '**/*',
        'base-directory': 'build/test-results',
      },
    },
  }),
});
```

Python:

```python
# source: codebuild.Source

# create a new ReportGroup
report_group = codebuild.ReportGroup(self, "ReportGroup")

project = codebuild.Project(self, "Project",
    source=source,
    build_spec=codebuild.BuildSpec.from_object({
        # ...
        "reports": {
            "report_group.report_group_arn": {
                "files": "**/*",
                "base-directory": "build/test-results"
            }
        }
    })
)
```

Java:

```java
Source source;

// create a new ReportGroup
ReportGroup reportGroup = new ReportGroup(this, "ReportGroup");

Project project = Project.Builder.create(this, "Project")
        .source(source)
        .buildSpec(BuildSpec.fromObject(Map.of(
                // ...
                "reports", Map.of(
                        reportGroup.getReportGroupArn(), Map.of(
                                "files", "**/*",
                                "base-directory", "build/test-results")))))
        .build();
```

C# / .NET:

```csharp
Source source;

// create a new ReportGroup
var reportGroup = new ReportGroup(this, "ReportGroup");

var project = new Project(this, "Project", new ProjectProps {
    Source = source,
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        // ...
        { "reports", new Dictionary<string, IDictionary<string, string>> {
            { reportGroup.ReportGroupArn, new Struct {
                Files = "**/*",
                Base-directory = "build/test-results"
            } }
        } }
    })
});
```

Golang:

```go
var source Source

// create a new ReportGroup
reportGroup := codebuild.NewReportGroup(this, jsii.String("ReportGroup"))

project := codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Source: Source,
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		// ...
		"reports": map[string]map[string]*string{
			reportGroup.reportGroupArn: map[string]*string{
				"files": jsii.String("**/*"),
				"base-directory": jsii.String("build/test-results"),
			},
		},
	}),
})
```

For a code coverage report, you can specify a report group with the code coverage report group type.

TypeScript:

```ts
declare const source: codebuild.Source;

// create a new ReportGroup
const reportGroup = new codebuild.ReportGroup(this, 'ReportGroup', {
    type: codebuild.ReportGroupType.CODE_COVERAGE
});

const project = new codebuild.Project(this, 'Project', {
  source,
  buildSpec: codebuild.BuildSpec.fromObject({
    // ...
    reports: {
      [reportGroup.reportGroupArn]: {
        files: '**/*',
        'base-directory': 'build/coverage-report.xml',
        'file-format': 'JACOCOXML'
      },
    },
  }),
});
```

Python:

```python
# source: codebuild.Source

# create a new ReportGroup
report_group = codebuild.ReportGroup(self, "ReportGroup",
    type=codebuild.ReportGroupType.CODE_COVERAGE
)

project = codebuild.Project(self, "Project",
    source=source,
    build_spec=codebuild.BuildSpec.from_object({
        # ...
        "reports": {
            "report_group.report_group_arn": {
                "files": "**/*",
                "base-directory": "build/coverage-report.xml",
                "file-format": "JACOCOXML"
            }
        }
    })
)
```

Java:

```java
Source source;

// create a new ReportGroup
ReportGroup reportGroup = ReportGroup.Builder.create(this, "ReportGroup")
        .type(ReportGroupType.CODE_COVERAGE)
        .build();

Project project = Project.Builder.create(this, "Project")
        .source(source)
        .buildSpec(BuildSpec.fromObject(Map.of(
                // ...
                "reports", Map.of(
                        reportGroup.getReportGroupArn(), Map.of(
                                "files", "**/*",
                                "base-directory", "build/coverage-report.xml",
                                "file-format", "JACOCOXML")))))
        .build();
```

C# / .NET:

```csharp
Source source;

// create a new ReportGroup
var reportGroup = new ReportGroup(this, "ReportGroup", new ReportGroupProps {
    Type = ReportGroupType.CODE_COVERAGE
});

var project = new Project(this, "Project", new ProjectProps {
    Source = source,
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        // ...
        { "reports", new Dictionary<string, IDictionary<string, string>> {
            { reportGroup.ReportGroupArn, new Struct {
                Files = "**/*",
                Base-directory = "build/coverage-report.xml",
                File-format = "JACOCOXML"
            } }
        } }
    })
});
```

Golang:

```go
var source Source

// create a new ReportGroup
reportGroup := codebuild.NewReportGroup(this, jsii.String("ReportGroup"), &ReportGroupProps{
	Type: codebuild.ReportGroupType_CODE_COVERAGE,
})

project := codebuild.NewProject(this, jsii.String("Project"), &ProjectProps{
	Source: Source,
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		// ...
		"reports": map[string]map[string]*string{
			reportGroup.reportGroupArn: map[string]*string{
				"files": jsii.String("**/*"),
				"base-directory": jsii.String("build/coverage-report.xml"),
				"file-format": jsii.String("JACOCOXML"),
			},
		},
	}),
})
```

If you specify a report group, you need to grant the project's role permissions to write reports to that report group:

TypeScript:

```ts
declare const project: codebuild.Project;
declare const reportGroup: codebuild.ReportGroup;

reportGroup.grantWrite(project);
```

Python:

```python
# project: codebuild.Project
# report_group: codebuild.ReportGroup

report_group.grant_write(project)
```

Java:

```java
Project project;
ReportGroup reportGroup;

reportGroup.grantWrite(project);
```

C# / .NET:

```csharp
Project project;
ReportGroup reportGroup;

reportGroup.GrantWrite(project);
```

Golang:

```go
var project Project
var reportGroup ReportGroup

reportGroup.grantWrite(project)
```

The created policy will adjust to the report group type. If no type is specified when creating the report group the created policy will contain the action for the test report group type.

For more information on the test reports feature,
see the [AWS CodeBuild documentation](https://docs.aws.amazon.com/codebuild/latest/userguide/test-reporting.html).

### Report group deletion

When a report group is removed from a stack (or the stack is deleted), the report
group will be removed according to its removal policy (which by default will
simply orphan the report group and leave it in your AWS account). If the removal
policy is set to `RemovalPolicy.DESTROY`, the report group will be deleted as long
as it does not contain any reports.

To override this and force all reports to get deleted during report group deletion,
enable the `deleteReports` option as well as setting the removal policy to
`RemovalPolicy.DESTROY`.

TypeScript:

```ts
import * as cdk from 'aws-cdk-lib';

const reportGroup = new codebuild.ReportGroup(this, 'ReportGroup', {
      removalPolicy: cdk.RemovalPolicy.DESTROY,
      deleteReports: true,
});
```

Python:

```python
import aws_cdk as cdk

report_group = codebuild.ReportGroup(self, "ReportGroup",
    removal_policy=cdk.RemovalPolicy.DESTROY,
    delete_reports=True
)
```

Java:

```java
import software.amazon.awscdk.*;

ReportGroup reportGroup = ReportGroup.Builder.create(this, "ReportGroup")
        .removalPolicy(RemovalPolicy.DESTROY)
        .deleteReports(true)
        .build();
```

C# / .NET:

```csharp
using Amazon.CDK;

var reportGroup = new ReportGroup(this, "ReportGroup", new ReportGroupProps {
    RemovalPolicy = RemovalPolicy.DESTROY,
    DeleteReports = true
});
```

Golang:

```go
import cdk "github.com/aws/aws-cdk-go/awscdk"

reportGroup := codebuild.NewReportGroup(this, jsii.String("ReportGroup"), &ReportGroupProps{
	RemovalPolicy: cdk.RemovalPolicy_DESTROY,
	DeleteReports: jsii.Boolean(true),
})
```

## Events

CodeBuild projects can be used either as a source for events or be triggered
by events via an event rule.

### Using Project as an event target

The `aws-cdk-lib/aws-events-targets.CodeBuildProject` allows using an AWS CodeBuild
project as a AWS CloudWatch event rule target:

TypeScript:

```ts
// start build when a commit is pushed
import * as codecommit from 'aws-cdk-lib/aws-codecommit';
import * as targets from 'aws-cdk-lib/aws-events-targets';

declare const codeCommitRepository: codecommit.Repository;
declare const project: codebuild.Project;

codeCommitRepository.onCommit('OnCommit', {
  target: new targets.CodeBuildProject(project),
});
```

Python:

```python
# start build when a commit is pushed
import aws_cdk.aws_codecommit as codecommit
import aws_cdk.aws_events_targets as targets

# code_commit_repository: codecommit.Repository
# project: codebuild.Project

code_commit_repository.on_commit("OnCommit",
    target=targets.CodeBuildProject(project)
)
```

Java:

```java
// start build when a commit is pushed
import software.amazon.awscdk.services.codecommit.*;
import software.amazon.awscdk.services.events.targets.*;

Repository codeCommitRepository;
Project project;

codeCommitRepository.onCommit("OnCommit", OnCommitOptions.builder()
        .target(new CodeBuildProject(project))
        .build());
```

C# / .NET:

```csharp
// start build when a commit is pushed
using Amazon.CDK.AWS.CodeCommit;
using Amazon.CDK.AWS.Events.Targets;

Repository codeCommitRepository;
Project project;

codeCommitRepository.OnCommit("OnCommit", new OnCommitOptions {
    Target = new CodeBuildProject(project)
});
```

Golang:

```go
// start build when a commit is pushed
import codecommit "github.com/aws/aws-cdk-go/awscdk"
import targets "github.com/aws/aws-cdk-go/awscdk"

var codeCommitRepository Repository
var project Project

codeCommitRepository.onCommit(jsii.String("OnCommit"), &OnCommitOptions{
	Target: targets.NewCodeBuildProject(project),
})
```

### Using Project as an event source

To define Amazon CloudWatch event rules for build projects, use one of the `onXxx`
methods:

TypeScript:

```ts
import * as targets from 'aws-cdk-lib/aws-events-targets';
declare const fn: lambda.Function;
declare const project: codebuild.Project;

const rule = project.onStateChange('BuildStateChange', {
  target: new targets.LambdaFunction(fn)
});
```

Python:

```python
import aws_cdk.aws_events_targets as targets
# fn: lambda.Function
# project: codebuild.Project

rule = project.on_state_change("BuildStateChange",
    target=targets.LambdaFunction(fn)
)
```

Java:

```java
import software.amazon.awscdk.services.events.targets.*;
Function fn;
Project project;

Rule rule = project.onStateChange("BuildStateChange", OnEventOptions.builder()
        .target(new LambdaFunction(fn))
        .build());
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.Events.Targets;
Function fn;
Project project;

var rule = project.OnStateChange("BuildStateChange", new OnEventOptions {
    Target = new LambdaFunction(fn)
});
```

Golang:

```go
import targets "github.com/aws/aws-cdk-go/awscdk"
var fn Function
var project Project

rule := project.onStateChange(jsii.String("BuildStateChange"), &OnEventOptions{
	Target: targets.NewLambdaFunction(fn),
})
```

## CodeStar Notifications

To define CodeStar Notification rules for Projects, use one of the `notifyOnXxx()` methods.
They are very similar to `onXxx()` methods for CloudWatch events:

TypeScript:

```ts
import * as chatbot from 'aws-cdk-lib/aws-chatbot';

declare const project: codebuild.Project;

const target = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', {
  slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
  slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
  slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
});

const rule = project.notifyOnBuildSucceeded('NotifyOnBuildSucceeded', target);
```

Python:

```python
import aws_cdk.aws_chatbot as chatbot

# project: codebuild.Project

target = chatbot.SlackChannelConfiguration(self, "MySlackChannel",
    slack_channel_configuration_name="YOUR_CHANNEL_NAME",
    slack_workspace_id="YOUR_SLACK_WORKSPACE_ID",
    slack_channel_id="YOUR_SLACK_CHANNEL_ID"
)

rule = project.notify_on_build_succeeded("NotifyOnBuildSucceeded", target)
```

Java:

```java
import software.amazon.awscdk.services.chatbot.*;

Project project;

SlackChannelConfiguration target = SlackChannelConfiguration.Builder.create(this, "MySlackChannel")
        .slackChannelConfigurationName("YOUR_CHANNEL_NAME")
        .slackWorkspaceId("YOUR_SLACK_WORKSPACE_ID")
        .slackChannelId("YOUR_SLACK_CHANNEL_ID")
        .build();

INotificationRule rule = project.notifyOnBuildSucceeded("NotifyOnBuildSucceeded", target);
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.Chatbot;

Project project;

var target = new SlackChannelConfiguration(this, "MySlackChannel", new SlackChannelConfigurationProps {
    SlackChannelConfigurationName = "YOUR_CHANNEL_NAME",
    SlackWorkspaceId = "YOUR_SLACK_WORKSPACE_ID",
    SlackChannelId = "YOUR_SLACK_CHANNEL_ID"
});

var rule = project.NotifyOnBuildSucceeded("NotifyOnBuildSucceeded", target);
```

Golang:

```go
import chatbot "github.com/aws/aws-cdk-go/awscdk"

var project Project

target := chatbot.NewSlackChannelConfiguration(this, jsii.String("MySlackChannel"), &SlackChannelConfigurationProps{
	SlackChannelConfigurationName: jsii.String("YOUR_CHANNEL_NAME"),
	SlackWorkspaceId: jsii.String("YOUR_SLACK_WORKSPACE_ID"),
	SlackChannelId: jsii.String("YOUR_SLACK_CHANNEL_ID"),
})

rule := project.notifyOnBuildSucceeded(jsii.String("NotifyOnBuildSucceeded"), target)
```

## Secondary sources and artifacts

CodeBuild Projects can get their sources from multiple places, and produce
multiple outputs. For example:

TypeScript:

```ts
import * as codecommit from 'aws-cdk-lib/aws-codecommit';
declare const repo: codecommit.Repository;
declare const bucket: s3.Bucket;

const project = new codebuild.Project(this, 'MyProject', {
  secondarySources: [
    codebuild.Source.codeCommit({
      identifier: 'source2',
      repository: repo,
    }),
  ],
  secondaryArtifacts: [
    codebuild.Artifacts.s3({
      identifier: 'artifact2',
      bucket: bucket,
      path: 'some/path',
      name: 'file.zip',
    }),
  ],
  // ...
});
```

Python:

```python
import aws_cdk.aws_codecommit as codecommit
# repo: codecommit.Repository
# bucket: s3.Bucket

project = codebuild.Project(self, "MyProject",
    secondary_sources=[
        codebuild.Source.code_commit(
            identifier="source2",
            repository=repo
        )
    ],
    secondary_artifacts=[
        codebuild.Artifacts.s3(
            identifier="artifact2",
            bucket=bucket,
            path="some/path",
            name="file.zip"
        )
    ]
)
```

Java:

```java
import software.amazon.awscdk.services.codecommit.*;
Repository repo;
Bucket bucket;

Project project = Project.Builder.create(this, "MyProject")
        .secondarySources(List.of(Source.codeCommit(CodeCommitSourceProps.builder()
                .identifier("source2")
                .repository(repo)
                .build())))
        .secondaryArtifacts(List.of(Artifacts.s3(S3ArtifactsProps.builder()
                .identifier("artifact2")
                .bucket(bucket)
                .path("some/path")
                .name("file.zip")
                .build())))
        .build();
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.CodeCommit;
Repository repo;
Bucket bucket;

var project = new Project(this, "MyProject", new ProjectProps {
    SecondarySources = new [] { Source.CodeCommit(new CodeCommitSourceProps {
        Identifier = "source2",
        Repository = repo
    }) },
    SecondaryArtifacts = new [] { Artifacts.S3(new S3ArtifactsProps {
        Identifier = "artifact2",
        Bucket = bucket,
        Path = "some/path",
        Name = "file.zip"
    }) }
});
```

Golang:

```go
import codecommit "github.com/aws/aws-cdk-go/awscdk"
var repo Repository
var bucket Bucket

project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	SecondarySources: []ISource{
		codebuild.Source_CodeCommit(&CodeCommitSourceProps{
			Identifier: jsii.String("source2"),
			Repository: repo,
		}),
	},
	SecondaryArtifacts: []IArtifacts{
		codebuild.Artifacts_S3(&S3ArtifactsProps{
			Identifier: jsii.String("artifact2"),
			Bucket: bucket,
			Path: jsii.String("some/path"),
			Name: jsii.String("file.zip"),
		}),
	},
})
```

Note that the `identifier` property is required for both secondary sources and
artifacts.

The contents of the secondary source is available to the build under the
directory specified by the `CODEBUILD_SRC_DIR_<identifier>` environment variable
(so, `CODEBUILD_SRC_DIR_source2` in the above case).

The secondary artifacts have their own section in the buildspec, under the
regular `artifacts` one. Each secondary artifact has its own section, beginning
with their identifier.

So, a buildspec for the above Project could look something like this:

TypeScript:

```ts
const project = new codebuild.Project(this, 'MyProject', {
  // secondary sources and artifacts as above...
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: [
          'cd $CODEBUILD_SRC_DIR_source2',
          'touch output2.txt',
        ],
      },
    },
    artifacts: {
      'secondary-artifacts': {
        'artifact2': {
          'base-directory': '$CODEBUILD_SRC_DIR_source2',
          'files': [
            'output2.txt',
          ],
        },
      },
    },
  }),
});
```

Python:

```python
project = codebuild.Project(self, "MyProject",
    # secondary sources and artifacts as above...
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["cd $CODEBUILD_SRC_DIR_source2", "touch output2.txt"
                ]
            }
        },
        "artifacts": {
            "secondary-artifacts": {
                "artifact2": {
                    "base-directory": "$CODEBUILD_SRC_DIR_source2",
                    "files": ["output2.txt"
                    ]
                }
            }
        }
    })
)
```

Java:

```java
Project project = Project.Builder.create(this, "MyProject")
        // secondary sources and artifacts as above...
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("cd $CODEBUILD_SRC_DIR_source2", "touch output2.txt"))),
                "artifacts", Map.of(
                        "secondary-artifacts", Map.of(
                                "artifact2", Map.of(
                                        "base-directory", "$CODEBUILD_SRC_DIR_source2",
                                        "files", List.of("output2.txt")))))))
        .build();
```

C# / .NET:

```csharp
var project = new Project(this, "MyProject", new ProjectProps {
    // secondary sources and artifacts as above...
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "cd $CODEBUILD_SRC_DIR_source2", "touch output2.txt" }
            } }
        } },
        { "artifacts", new Dictionary<string, IDictionary<string, IDictionary<string, object>>> {
            { "secondary-artifacts", new Struct {
                Artifact2 = new Struct {
                    Base-directory = "$CODEBUILD_SRC_DIR_source2",
                    Files = new [] { "output2.txt" }
                }
            } }
        } }
    })
});
```

Golang:

```go
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	// secondary sources and artifacts as above...
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("cd $CODEBUILD_SRC_DIR_source2"),
					jsii.String("touch output2.txt"),
				},
			},
		},
		"artifacts": map[string]map[string]map[string]interface{}{
			"secondary-artifacts": map[string]map[string]interface{}{
				"artifact2": map[string]interface{}{
					"base-directory": jsii.String("$CODEBUILD_SRC_DIR_source2"),
					"files": []*string{
						jsii.String("output2.txt"),
					},
				},
			},
		},
	}),
})
```

### Definition of VPC configuration in CodeBuild Project

Typically, resources in an VPC are not accessible by AWS CodeBuild. To enable
access, you must provide additional VPC-specific configuration information as
part of your CodeBuild project configuration. This includes the VPC ID, the
VPC subnet IDs, and the VPC security group IDs. VPC-enabled builds are then
able to access resources inside your VPC.

For further Information see https://docs.aws.amazon.com/codebuild/latest/userguide/vpc-support.html

**Use Cases**
VPC connectivity from AWS CodeBuild builds makes it possible to:

* Run integration tests from your build against data in an Amazon RDS database that's isolated on a private subnet.
* Query data in an Amazon ElastiCache cluster directly from tests.
* Interact with internal web services hosted on Amazon EC2, Amazon ECS, or services that use internal Elastic Load Balancing.
* Retrieve dependencies from self-hosted, internal artifact repositories, such as PyPI for Python, Maven for Java, and npm for Node.js.
* Access objects in an Amazon S3 bucket configured to allow access through an Amazon VPC endpoint only.
* Query external web services that require fixed IP addresses through the Elastic IP address of the NAT gateway or NAT instance associated with your subnet(s).

Your builds can access any resource that's hosted in your VPC.

**Enable Amazon VPC Access in your CodeBuild Projects**

Pass the VPC when defining your Project, then make sure to
give the CodeBuild's security group the right permissions
to access the resources that it needs by using the
`connections` object.

For example:

TypeScript:

```ts
declare const loadBalancer: elbv2.ApplicationLoadBalancer;

const vpc = new ec2.Vpc(this, 'MyVPC');
const project = new codebuild.Project(this, 'MyProject', {
  vpc: vpc,
  buildSpec: codebuild.BuildSpec.fromObject({
    // ...
  }),
});

project.connections.allowTo(loadBalancer, ec2.Port.tcp(443));
```

Python:

```python
# load_balancer: elbv2.ApplicationLoadBalancer

vpc = ec2.Vpc(self, "MyVPC")
project = codebuild.Project(self, "MyProject",
    vpc=vpc,
    build_spec=codebuild.BuildSpec.from_object({})
)

project.connections.allow_to(load_balancer, ec2.Port.tcp(443))
```

Java:

```java
ApplicationLoadBalancer loadBalancer;

Vpc vpc = new Vpc(this, "MyVPC");
Project project = Project.Builder.create(this, "MyProject")
        .vpc(vpc)
        .buildSpec(BuildSpec.fromObject(Map.of()))
        .build();

project.connections.allowTo(loadBalancer, Port.tcp(443));
```

C# / .NET:

```csharp
ApplicationLoadBalancer loadBalancer;

var vpc = new Vpc(this, "MyVPC");
var project = new Project(this, "MyProject", new ProjectProps {
    Vpc = vpc,
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> { })
});

project.Connections.AllowTo(loadBalancer, Port.Tcp(443));
```

Golang:

```go
var loadBalancer ApplicationLoadBalancer

vpc := ec2.NewVpc(this, jsii.String("MyVPC"))
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Vpc: vpc,
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
	}),
})

project.connections.AllowTo(loadBalancer, ec2.Port_Tcp(jsii.Number(443)))
```

## Project File System Location EFS

Add support for CodeBuild to build on AWS EFS file system mounts using
the new ProjectFileSystemLocation.
The `fileSystemLocations` property which accepts a list `ProjectFileSystemLocation`
as represented by the interface `IFileSystemLocations`.
The only supported file system type is `EFS`.

For example:

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
  }),
  fileSystemLocations: [
    codebuild.FileSystemLocation.efs({
      identifier: "myidentifier2",
      location: "myclodation.mydnsroot.com:/loc",
      mountPoint: "/media",
      mountOptions: "opts"
    })
  ]
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2"
    }),
    file_system_locations=[
        codebuild.FileSystemLocation.efs(
            identifier="myidentifier2",
            location="myclodation.mydnsroot.com:/loc",
            mount_point="/media",
            mount_options="opts"
        )
    ]
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2")))
        .fileSystemLocations(List.of(FileSystemLocation.efs(EfsFileSystemLocationProps.builder()
                .identifier("myidentifier2")
                .location("myclodation.mydnsroot.com:/loc")
                .mountPoint("/media")
                .mountOptions("opts")
                .build())))
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" }
    }),
    FileSystemLocations = new [] { FileSystemLocation.Efs(new EfsFileSystemLocationProps {
        Identifier = "myidentifier2",
        Location = "myclodation.mydnsroot.com:/loc",
        MountPoint = "/media",
        MountOptions = "opts"
    }) }
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
	}),
	FileSystemLocations: []IFileSystemLocation{
		codebuild.FileSystemLocation_Efs(&EfsFileSystemLocationProps{
			Identifier: jsii.String("myidentifier2"),
			Location: jsii.String("myclodation.mydnsroot.com:/loc"),
			MountPoint: jsii.String("/media"),
			MountOptions: jsii.String("opts"),
		}),
	},
})
```

Here's a CodeBuild project with a simple example that creates a project mounted on AWS EFS:

Minimal Example

## Batch builds

To enable batch builds you should call `enableBatchBuilds()` on the project instance.

It returns an object containing the batch service role that was created,
or `undefined` if batch builds could not be enabled, for example if the project was imported.

TypeScript:

```ts
declare const source: codebuild.Source;

const project = new codebuild.Project(this, 'MyProject', { source, });

if (project.enableBatchBuilds()) {
  console.log('Batch builds were enabled');
}
```

Python:

```python
# source: codebuild.Source

project = codebuild.Project(self, "MyProject", source=source)

if project.enable_batch_builds():
    print("Batch builds were enabled")
```

Java:

```java
Source source;

Project project = Project.Builder.create(this, "MyProject").source(source).build();

if (project.enableBatchBuilds()) {
    System.out.println("Batch builds were enabled");
}
```

C# / .NET:

```csharp
Source source;

var project = new Project(this, "MyProject", new ProjectProps { Source = source });

if (project.EnableBatchBuilds())
{
    Console.WriteLine("Batch builds were enabled");
}
```

Golang:

```go
var source Source

project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Source: Source,
})

if project.EnableBatchBuilds() {
	fmt.Println("Batch builds were enabled")
}
```

## Timeouts

There are two types of timeouts that can be set when creating your Project.
The `timeout` property can be used to set an upper limit on how long your Project is able to run without being marked as completed.
The default is 60 minutes.
An example of overriding the default follows.

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  timeout: Duration.minutes(90)
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    timeout=Duration.minutes(90)
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .timeout(Duration.minutes(90))
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    Timeout = Duration.Minutes(90)
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Timeout: awscdk.Duration_Minutes(jsii.Number(90)),
})
```

The `queuedTimeout` property can be used to set an upper limit on how your Project remains queued to run.
There is no default value for this property.
As an example, to allow your Project to queue for up to thirty (30) minutes before the build fails,
use the following code.

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  queuedTimeout: Duration.minutes(30)
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    queued_timeout=Duration.minutes(30)
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .queuedTimeout(Duration.minutes(30))
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    QueuedTimeout = Duration.Minutes(30)
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	QueuedTimeout: awscdk.Duration_Minutes(jsii.Number(30)),
})
```

## Limiting concurrency

By default if a new build is triggered it will be run even if there is a previous build already in progress.
It is possible to limit the maximum concurrent builds to value between 1 and the account specific maximum limit.
By default there is no explicit limit.

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  concurrentBuildLimit: 1
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    concurrent_build_limit=1
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .concurrentBuildLimit(1)
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    ConcurrentBuildLimit = 1
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	ConcurrentBuildLimit: jsii.Number(1),
})
```

## Visibility
When you can specify the visibility of the project builds. This setting controls whether the builds are publicly readable or remain private.

Visibility options:
- `PUBLIC_READ`: The project builds are visible to the public.
- `PRIVATE`: The project builds are not visible to the public.

Examples:

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  visibility: codebuild.ProjectVisibility.PUBLIC_READ,
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    visibility=codebuild.ProjectVisibility.PUBLIC_READ
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .visibility(ProjectVisibility.PUBLIC_READ)
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    Visibility = ProjectVisibility.PUBLIC_READ
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	Visibility: codebuild.ProjectVisibility_PUBLIC_READ,
})
```

## Auto retry limit
You can automatically retry your builds in AWS CodeBuild by setting `autoRetryLimit` property.

With auto-retry enabled, CodeBuild will automatically call RetryBuild using the project's service role after a failed build up to a specified limit.

For example, if the auto-retry limit is set to two, CodeBuild will call the RetryBuild API to automatically retry your build for up to two additional times.

TypeScript:

```ts
new codebuild.Project(this, 'MyProject', {
  autoRetryLimit: 2,
});
```

Python:

```python
codebuild.Project(self, "MyProject",
    auto_retry_limit=2
)
```

Java:

```java
Project.Builder.create(this, "MyProject")
        .autoRetryLimit(2)
        .build();
```

C# / .NET:

```csharp
new Project(this, "MyProject", new ProjectProps {
    AutoRetryLimit = 2
});
```

Golang:

```go
codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
	AutoRetryLimit: jsii.Number(2),
})
```

## Types

### Constructs (L2)

- [`BitBucketSourceCredentials`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BitBucketSourceCredentials.html) Construct (L2) The source credentials used when contacting the BitBucket API.
- [`Fleet`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Fleet.html) Construct (L2) Fleet for a reserved capacity CodeBuild project.
- [`GitHubEnterpriseSourceCredentials`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubEnterpriseSourceCredentials.html) Construct (L2) The source credentials used when contacting the GitHub Enterprise API.
- [`GitHubSourceCredentials`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubSourceCredentials.html) Construct (L2) The source credentials used when contacting the GitHub API.
- [`PipelineProject`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.PipelineProject.html) Construct (L2) A convenience class for CodeBuild Projects that are used in CodePipeline.
- [`Project`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Project.html) Construct (L2) A representation of a CodeBuild Project.
- [`ReportGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ReportGroup.html) Construct (L2) The ReportGroup resource class.
- [`UntrustedCodeBoundaryPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.UntrustedCodeBoundaryPolicy.html) Construct (L2) Permissions Boundary for a CodeBuild Project running untrusted code.

### Constructs (L1)

- [`CfnFleet`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.html) Construct (L1) The `AWS::CodeBuild::Fleet` resource configures a compute fleet, a set of dedicated instances for your build environment.
- [`CfnProject`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.html) Construct (L1) The `AWS::CodeBuild::Project` resource configures how AWS CodeBuild builds your source code.
- [`CfnReportGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnReportGroup.html) Construct (L1) Represents a report group.
- [`CfnSourceCredential`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnSourceCredential.html) Construct (L1) Information about the credentials for a GitHub, GitHub Enterprise, or Bitbucket repository.

### Classes

- [`Artifacts`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Artifacts.html) Class Artifacts definition for a CodeBuild Project.
- [`BuildSpec`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildSpec.html) Class BuildSpec for CodeBuild projects.
- [`Cache`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Cache.html) Class Cache options for CodeBuild Project.
- [`FileSystemLocation`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FileSystemLocation.html) Class FileSystemLocation provider definition for a CodeBuild Project.
- [`FilterGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FilterGroup.html) Class An object that represents a group of filter conditions for a webhook.
- [`LinuxArmBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmBuildImage.html) Class A CodeBuild image running aarch64 Linux.
- [`LinuxArmLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxArmLambdaBuildImage.html) Class A CodeBuild image running aarch64 Lambda.
- [`LinuxBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxBuildImage.html) Class A CodeBuild image running x86-64 Linux.
- [`LinuxGpuBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxGpuBuildImage.html) Class A CodeBuild GPU image running Linux.
- [`LinuxLambdaBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LinuxLambdaBuildImage.html) Class A CodeBuild image running x86-64 Lambda.
- [`MacBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.MacBuildImage.html) Class A CodeBuild image running ARM MacOS.
- [`PhaseChangeEvent`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.PhaseChangeEvent.html) Class Event fields for the CodeBuild "phase change" event.
- [`Source`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Source.html) Class Source provider definition for a CodeBuild Project.
- [`StateChangeEvent`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.StateChangeEvent.html) Class Event fields for the CodeBuild "state change" event.
- [`WindowsBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsBuildImage.html) Class A CodeBuild image running Windows.

### Structs

- [`ArtifactsConfig`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ArtifactsConfig.html) Struct The type returned from `IArtifacts#bind`.
- [`ArtifactsProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ArtifactsProps.html) Struct Properties common to all Artifacts classes.
- [`BatchBuildConfig`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BatchBuildConfig.html) Struct The type returned from `IProject#enableBatchBuilds`.
- [`BindToCodePipelineOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BindToCodePipelineOptions.html) Struct The extra options passed to the `IProject.bindToCodePipeline` method.
- [`BitBucketSourceCredentialsProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BitBucketSourceCredentialsProps.html) Struct Construction properties of `BitBucketSourceCredentials`.
- [`BitBucketSourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BitBucketSourceProps.html) Struct Construction properties for `BitBucketSource`.
- [`BucketCacheOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BucketCacheOptions.html) Struct
- [`BuildEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironment.html) Struct
- [`BuildEnvironmentCertificate`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironmentCertificate.html) Struct Location of a PEM certificate on S3.
- [`BuildEnvironmentVariable`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironmentVariable.html) Struct
- [`BuildImageBindOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildImageBindOptions.html) Struct Optional arguments to `IBuildImage.binder` - currently empty.
- [`BuildImageConfig`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildImageConfig.html) Struct The return type from `IBuildImage.binder` - currently empty.
- [`CfnFleet.ComputeConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.ComputeConfigurationProperty.html) Struct Contains compute attributes.
- [`CfnFleet.FleetProxyRuleProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.FleetProxyRuleProperty.html) Struct Information about the proxy rule for your reserved capacity instances.
- [`CfnFleet.ProxyConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.ProxyConfigurationProperty.html) Struct Information about the proxy configurations that apply network access control to your reserved capacity instances.
- [`CfnFleet.ScalingConfigurationInputProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.ScalingConfigurationInputProperty.html) Struct The scaling configuration input of a compute fleet.
- [`CfnFleet.TargetTrackingScalingConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.TargetTrackingScalingConfigurationProperty.html) Struct Defines when a new instance is auto-scaled into the compute fleet.
- [`CfnFleet.VpcConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleet.VpcConfigProperty.html) Struct Information about the VPC configuration that AWS CodeBuild accesses.
- [`CfnFleetProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnFleetProps.html) Struct Properties for defining a `CfnFleet`.
- [`CfnProject.ArtifactsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ArtifactsProperty.html) Struct `Artifacts` is a property of the [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies output settings for artifacts generated by an AWS CodeBuild build.
- [`CfnProject.BatchRestrictionsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.BatchRestrictionsProperty.html) Struct Specifies restrictions for the batch build.
- [`CfnProject.BuildStatusConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.BuildStatusConfigProperty.html) Struct Contains information that defines how the AWS CodeBuild build project reports the build status to the source provider.
- [`CfnProject.CloudWatchLogsConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.CloudWatchLogsConfigProperty.html) Struct `CloudWatchLogs` is a property of the [AWS CodeBuild Project LogsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-logsconfig.html) property type that specifies settings for CloudWatch logs generated by an AWS CodeBuild build.
- [`CfnProject.DockerServerProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.DockerServerProperty.html) Struct
- [`CfnProject.EnvironmentProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.EnvironmentProperty.html) Struct `Environment` is a property of the [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies the environment for an AWS CodeBuild project.
- [`CfnProject.EnvironmentVariableProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.EnvironmentVariableProperty.html) Struct `EnvironmentVariable` is a property of the [AWS CodeBuild Project Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html) property type that specifies the name and value of an environment variable for an AWS CodeBuild project environment. When you use the environment to run a build, these variables are available for your builds to use. `EnvironmentVariable` contains a list of `EnvironmentVariable` property types.
- [`CfnProject.GitSubmodulesConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.GitSubmodulesConfigProperty.html) Struct `GitSubmodulesConfig` is a property of the [AWS CodeBuild Project Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html) property type that specifies information about the Git submodules configuration for the build project.
- [`CfnProject.LogsConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.LogsConfigProperty.html) Struct `LogsConfig` is a property of the [AWS CodeBuild Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies information about logs for a build project. These can be logs in Amazon CloudWatch Logs, built in a specified S3 bucket, or both.
- [`CfnProject.ProjectBuildBatchConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectBuildBatchConfigProperty.html) Struct Contains configuration information about a batch build project.
- [`CfnProject.ProjectCacheProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectCacheProperty.html) Struct `ProjectCache` is a property of the [AWS CodeBuild Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies information about the cache for the build project. If `ProjectCache` is not specified, then both of its properties default to `NO_CACHE` .
- [`CfnProject.ProjectFileSystemLocationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectFileSystemLocationProperty.html) Struct Information about a file system created by Amazon Elastic File System (EFS).
- [`CfnProject.ProjectFleetProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectFleetProperty.html) Struct Information about the compute fleet of the build project.
- [`CfnProject.ProjectSourceVersionProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectSourceVersionProperty.html) Struct A source identifier and its corresponding version.
- [`CfnProject.ProjectTriggersProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ProjectTriggersProperty.html) Struct `ProjectTriggers` is a property of the [AWS CodeBuild Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies webhooks that trigger an AWS CodeBuild build.
- [`CfnProject.PullRequestBuildPolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.PullRequestBuildPolicyProperty.html) Struct
- [`CfnProject.RegistryCredentialProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.RegistryCredentialProperty.html) Struct `RegistryCredential` is a property of the [AWS CodeBuild Project Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-environment.html) property type that specifies information about credentials that provide access to a private Docker registry. When this is set:.
- [`CfnProject.S3LogsConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.S3LogsConfigProperty.html) Struct `S3Logs` is a property of the [AWS CodeBuild Project LogsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-logsconfig.html) property type that specifies settings for logs generated by an AWS CodeBuild build in an S3 bucket.
- [`CfnProject.ScopeConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.ScopeConfigurationProperty.html) Struct Contains configuration information about the scope for a webhook.
- [`CfnProject.SourceAuthProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.SourceAuthProperty.html) Struct `SourceAuth` is a property of the [AWS CodeBuild Project Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-source.html) property type that specifies authorization settings for AWS CodeBuild to access the source code to be built.
- [`CfnProject.SourceProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.SourceProperty.html) Struct `Source` is a property of the [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that specifies the source code settings for the project, such as the source code's repository type and location.
- [`CfnProject.VpcConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.VpcConfigProperty.html) Struct `VpcConfig` is a property of the [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) resource that enable AWS CodeBuild to access resources in an Amazon VPC. For more information, see [Use AWS CodeBuild with Amazon Virtual Private Cloud](https://docs.aws.amazon.com/codebuild/latest/userguide/vpc-support.html) in the *AWS CodeBuild User Guide* .
- [`CfnProject.WebhookFilterProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProject.WebhookFilterProperty.html) Struct `WebhookFilter` is a structure of the `FilterGroups` property on the [AWS CodeBuild Project ProjectTriggers](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-projecttriggers.html) property type that specifies which webhooks trigger an AWS CodeBuild build.
- [`CfnProjectProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnProjectProps.html) Struct Properties for defining a `CfnProject`.
- [`CfnReportGroup.ReportExportConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnReportGroup.ReportExportConfigProperty.html) Struct Information about the location where the run of a report is exported.
- [`CfnReportGroup.S3ReportExportConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnReportGroup.S3ReportExportConfigProperty.html) Struct Information about the S3 bucket where the raw data of a report are exported.
- [`CfnReportGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnReportGroupProps.html) Struct Properties for defining a `CfnReportGroup`.
- [`CfnSourceCredentialProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CfnSourceCredentialProps.html) Struct Properties for defining a `CfnSourceCredential`.
- [`CloudWatchLoggingOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CloudWatchLoggingOptions.html) Struct Information about logs built to a CloudWatch Log Group for a build project.
- [`CodeCommitSourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CodeCommitSourceProps.html) Struct Construction properties for `CodeCommitSource`.
- [`CommonProjectProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.CommonProjectProps.html) Struct
- [`ComputeConfiguration`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeConfiguration.html) Struct The compute configuration for the fleet.
- [`DockerImageOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.DockerImageOptions.html) Struct The options when creating a CodeBuild Docker build image using `LinuxBuildImage.fromDockerRegistry`, `WindowsBuildImage.fromDockerRegistry`, or `MacBuildImage.fromDockerRegistry`.
- [`DockerServerOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.DockerServerOptions.html) Struct The Docker server configuration CodeBuild use to build your Docker image.
- [`EfsFileSystemLocationProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.EfsFileSystemLocationProps.html) Struct Construction properties for `EfsFileSystemLocation`.
- [`FileSystemConfig`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FileSystemConfig.html) Struct The type returned from `IFileSystemLocation#bind`.
- [`FleetProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FleetProps.html) Struct Construction properties of a CodeBuild Fleet.
- [`GitHubEnterpriseSourceCredentialsProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubEnterpriseSourceCredentialsProps.html) Struct Creation properties for `GitHubEnterpriseSourceCredentials`.
- [`GitHubEnterpriseSourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubEnterpriseSourceProps.html) Struct Construction properties for `GitHubEnterpriseSource`.
- [`GitHubSourceCredentialsProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubSourceCredentialsProps.html) Struct Creation properties for `GitHubSourceCredentials`.
- [`GitHubSourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubSourceProps.html) Struct Construction properties for `GitHubSource` and `GitHubEnterpriseSource`.
- [`LoggingOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LoggingOptions.html) Struct Information about logs for the build project.
- [`PipelineProjectProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.PipelineProjectProps.html) Struct
- [`ProjectNotifyOnOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ProjectNotifyOnOptions.html) Struct Additional options to pass to the notification rule.
- [`ProjectProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ProjectProps.html) Struct
- [`ReportGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ReportGroupProps.html) Struct Construction properties for `ReportGroup`.
- [`S3ArtifactsProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.S3ArtifactsProps.html) Struct Construction properties for `S3Artifacts`.
- [`S3LoggingOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.S3LoggingOptions.html) Struct Information about logs built to an S3 bucket for a build project.
- [`S3SourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.S3SourceProps.html) Struct Construction properties for `S3Source`.
- [`SourceConfig`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.SourceConfig.html) Struct The type returned from `ISource#bind`.
- [`SourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.SourceProps.html) Struct Properties common to all Source classes.
- [`UntrustedCodeBoundaryPolicyProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.UntrustedCodeBoundaryPolicyProps.html) Struct Construction properties for UntrustedCodeBoundaryPolicy.

### Enums

- [`BuildEnvironmentVariableType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironmentVariableType.html) Enum
- [`ComputeType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeType.html) Enum Build machine compute type.
- [`DockerServerComputeType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.DockerServerComputeType.html) Enum Docker server compute type.
- [`EnvironmentType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.EnvironmentType.html) Enum Build environment type.
- [`EventAction`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.EventAction.html) Enum The types of webhook event actions.
- [`FleetComputeType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FleetComputeType.html) Enum Fleet build machine compute type. Subset of Fleet compatible ComputeType values.
- [`FleetOverflowBehavior`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.FleetOverflowBehavior.html) Enum The compute fleet overflow behavior.
- [`HostKernel`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.HostKernel.html) Enum The host operating system kernel used for builds in a CodeBuild project.
- [`ImagePullPrincipalType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ImagePullPrincipalType.html) Enum The type of principal CodeBuild will use to pull your build Docker image.
- [`LocalCacheMode`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LocalCacheMode.html) Enum Local cache modes to enable for the CodeBuild Project.
- [`MachineType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.MachineType.html) Enum The compute type of the fleet.
- [`ProjectNotificationEvents`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ProjectNotificationEvents.html) Enum The list of event types for AWS Codebuild.
- [`ProjectVisibility`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ProjectVisibility.html) Enum Specifies the visibility of the project's builds.
- [`ReportGroupType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ReportGroupType.html) Enum The type of reports in the report group.
- [`WindowsImageType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.WindowsImageType.html) Enum Environment type for Windows Docker images.

### Interfaces

- [`IArtifacts`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IArtifacts.html) Interface The abstract interface of a CodeBuild build output.
- [`IBindableBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBindableBuildImage.html) Interface A variant of `IBuildImage` that allows binding to the project.
- [`IBuildImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) Interface Represents a Docker image used for the CodeBuild Project builds.
- [`IFileSystemLocation`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IFileSystemLocation.html) Interface The interface of a CodeBuild FileSystemLocation.
- [`IFleet`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IFleet.html) Interface Represents a Fleet for a reserved capacity CodeBuild project.
- [`IProject`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IProject.html) Interface
- [`IReportGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IReportGroup.html) Interface The interface representing the ReportGroup resource - either an existing one, imported using the `ReportGroup.fromReportGroupName` method, or a new one, created with the `ReportGroup` class.
- [`ISource`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ISource.html) Interface The abstract interface of a CodeBuild source.
