# WindowsBuildImage

A CodeBuild image running Windows.

This class has a bunch of public constants that represent the most popular images.

You can also specify a custom image using one of the static methods:

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

Extends: WindowsBuildImage
Implements: IBuildImage

- Source: [`aws-codebuild/lib/project.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codebuild/lib/project.ts#L2067)
- Type last changed: v2.145.0 · 7 Jun 2024

## Example

```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',
    },
  },
  // ...
})
```

## Properties

- `defaultComputeType`: [ComputeType](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeType.html) — The default `ComputeType` to use with this image, if one was not specified in `BuildEnvironment#computeType` explicitly.

- `imageId`: string — The Docker image identifier that the build environment uses.

- `imagePullPrincipalType`: [ImagePullPrincipalType](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ImagePullPrincipalType.html) — The type of principal that CodeBuild will use to pull this build Docker image.

- `repository`: [IRepository](/cdk/api/v2/docs/aws-cdk-lib.aws_ecr.IRepository.html) — An optional ECR repository that the image is hosted in.

- `secretsManagerCredentials`: [ISecret](/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) — The secretsManagerCredentials for access to a private registry.

- `type`: string — The type of build environment.

- `WIN_SERVER_CORE_2019_BASE`: [IBuildImage](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) (static) — The standard CodeBuild image `aws/codebuild/windows-base:2019-1.0`, which is based off Windows Server Core 2019.

- `WIN_SERVER_CORE_2019_BASE_2_0`: [IBuildImage](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) (static) — The standard CodeBuild image `aws/codebuild/windows-base:2019-2.0`, which is based off Windows Server Core 2019.

- `WIN_SERVER_CORE_2019_BASE_3_0`: [IBuildImage](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) (static) — The standard CodeBuild image `aws/codebuild/windows-base:2019-3.0`, which is based off Windows Server Core 2019.

- `WIN_SERVER_CORE_2022_BASE_3_0`: [IBuildImage](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) (static) — The standard CodeBuild image `aws/codebuild/windows-base:2022-1.0`, which is based off Windows Server Core 2022.

  Notice: Cannot be used with on-demand compute, only with a {@link BuildEnvironment.fleet}.

- `WINDOWS_BASE_2_0`: [IBuildImage](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IBuildImage.html) (static) — {@link WindowsBuildImage.WIN_SERVER_CORE_2019_BASE_3_0 } should be used instead.

## Methods

- `fromAsset(scope: Construct, id: string, props: DockerImageAssetProps, imageType?: WindowsImageType): IBuildImage` (static) — Uses an Docker image asset as a Windows build image.

- `fromDockerRegistry(name: string, options?: DockerImageOptions, imageType?: WindowsImageType): IBuildImage` (static)

  **Returns:** a Windows build image from a Docker Hub image.

- `fromEcrRepository(repository: IRepository, tagOrDigest?: string, imageType?: WindowsImageType): IBuildImage` (static)

  **Parameters**

  - `repository` — The ECR repository.
  - `tagOrDigest` — Image tag or digest (default "latest", digests must start with `sha256:`).

  **Returns:** A Windows build image from an ECR repository. NOTE: if the repository is external (i.e. imported), then we won't be able to add a resource policy statement for it so CodeBuild can pull the image.

- `runScriptBuildspec(entrypoint: string): BuildSpec` — Make a buildspec to run the indicated script.

- `validate(buildEnvironment: BuildEnvironment): string[]` — Allows the image a chance to validate whether the passed configuration is correct.
