aws-cdk-lib.aws_codebuild.WindowsBuildImage

class WindowsBuildImage

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.WindowsBuildImage
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#WindowsBuildImage
Javasoftware.amazon.awscdk.services.codebuild.WindowsBuildImage
Pythonaws_cdk.aws_codebuild.WindowsBuildImage
TypeScript (source)aws-cdk-lib » aws_codebuild » WindowsBuildImage

Implements IBuildImage

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])

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html

Example

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', 'my-bucket'),
      objectKey: 'path/to/cert.pem',
    },
  },
  // ...
})

Properties

NameTypeDescription
defaultComputeTypeComputeTypeThe default ComputeType to use with this image, if one was not specified in BuildEnvironment#computeType explicitly.
imageIdstringThe Docker image identifier that the build environment uses.
typestringThe type of build environment.
imagePullPrincipalType?ImagePullPrincipalTypeThe type of principal that CodeBuild will use to pull this build Docker image.
repository?IRepositoryAn optional ECR repository that the image is hosted in.
secretsManagerCredentials?ISecretThe secretsManagerCredentials for access to a private registry.
static WINDOWS_BASE_2_0IBuildImageThe standard CodeBuild image aws/codebuild/windows-base:2.0, which is based off Windows Server Core 2016.
static WIN_SERVER_CORE_2019_BASEIBuildImageThe standard CodeBuild image aws/codebuild/windows-base:2019-1.0, which is based off Windows Server Core 2019.
static WIN_SERVER_CORE_2019_BASE_2_0IBuildImageThe standard CodeBuild image aws/codebuild/windows-base:2019-2.0, which is based off Windows Server Core 2019.

defaultComputeType

Type: ComputeType

The default ComputeType to use with this image, if one was not specified in BuildEnvironment#computeType explicitly.


imageId

Type: string

The Docker image identifier that the build environment uses.


type

Type: string

The type of build environment.


imagePullPrincipalType?

Type: ImagePullPrincipalType (optional)

The type of principal that CodeBuild will use to pull this build Docker image.


repository?

Type: IRepository (optional)

An optional ECR repository that the image is hosted in.


secretsManagerCredentials?

Type: ISecret (optional)

The secretsManagerCredentials for access to a private registry.


static WINDOWS_BASE_2_0

Type: IBuildImage

The standard CodeBuild image aws/codebuild/windows-base:2.0, which is based off Windows Server Core 2016.


static WIN_SERVER_CORE_2019_BASE

Type: IBuildImage

The standard CodeBuild image aws/codebuild/windows-base:2019-1.0, which is based off Windows Server Core 2019.


static WIN_SERVER_CORE_2019_BASE_2_0

Type: IBuildImage

The standard CodeBuild image aws/codebuild/windows-base:2019-2.0, which is based off Windows Server Core 2019.

Methods

NameDescription
runScriptBuildspec(entrypoint)Make a buildspec to run the indicated script.
validate(buildEnvironment)Allows the image a chance to validate whether the passed configuration is correct.
static fromAsset(scope, id, props, imageType?)Uses an Docker image asset as a Windows build image.
static fromDockerRegistry(name, options?, imageType?)
static fromEcrRepository(repository, tagOrDigest?, imageType?)

runScriptBuildspec(entrypoint)

public runScriptBuildspec(entrypoint: string): BuildSpec

Parameters

  • entrypoint string

Returns

  • BuildSpec

Make a buildspec to run the indicated script.


validate(buildEnvironment)

public validate(buildEnvironment: BuildEnvironment): string[]

Parameters

  • buildEnvironment BuildEnvironment

Returns

  • string[]

Allows the image a chance to validate whether the passed configuration is correct.


static fromAsset(scope, id, props, imageType?)

public static fromAsset(scope: Construct, id: string, props: DockerImageAssetProps, imageType?: WindowsImageType): IBuildImage

Parameters

  • scope Construct
  • id string
  • props DockerImageAssetProps
  • imageType WindowsImageType

Returns

  • IBuildImage

Uses an Docker image asset as a Windows build image.


static fromDockerRegistry(name, options?, imageType?)

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

Parameters

  • name string
  • options DockerImageOptions
  • imageType WindowsImageType

Returns

  • IBuildImage

static fromEcrRepository(repository, tagOrDigest?, imageType?)

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

Parameters

  • repository IRepository — The ECR repository.
  • tagOrDigest string — Image tag or digest (default "latest", digests must start with sha256:).
  • imageType WindowsImageType

Returns

  • IBuildImage

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html