From c60ce2e4b1b84935c46d12e59082a66dc1cac51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Wed, 25 Mar 2020 12:59:37 +0100 Subject: [PATCH] feat(codebuild): expose aws/windows/base:2.0 image The 1.0 version of this image, while still supported by the service, is no longer documented on the CodeBuild supported images documentation. Users are recommended to upgrade to the 2.0 version of the image, which also comes with up-to-date versions of Node, DotNet SDK, etc... This PR makes a new `WindowsBuildImage.WINDOWS_BASE_2_0` constant available to easily access this build image, and proceeds to deprecate the older `WindowsBuildImage.WIN_SERVER_CORE_2016_BASE` image. --- packages/@aws-cdk/aws-codebuild/README.md | 2 +- packages/@aws-cdk/aws-codebuild/lib/project.ts | 14 ++++++++++++++ packages/@aws-cdk/aws-codebuild/package.json | 1 - .../@aws-cdk/aws-codebuild/test/test.codebuild.ts | 6 +++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/aws-codebuild/README.md b/packages/@aws-cdk/aws-codebuild/README.md index b0deca2a1033a..f32cf889cd3e0 100644 --- a/packages/@aws-cdk/aws-codebuild/README.md +++ b/packages/@aws-cdk/aws-codebuild/README.md @@ -189,7 +189,7 @@ The CodeBuild library supports both Linux and Windows images via the `LinuxBuildImage` and `WindowsBuildImage` classes, respectively. You can either specify one of the predefined Windows/Linux images by using one -of the constants such as `WindowsBuildImage.WIN_SERVER_CORE_2016_BASE` or +of the constants such as `WindowsBuildImage.WINDOWS_BASE_2_0` or `LinuxBuildImage.UBUNTU_14_04_RUBY_2_5_1`. Alternatively, you can specify a custom image using one of the static methods on diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index fe7768a3512e1..88991ab0de3f7 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -1390,11 +1390,25 @@ interface WindowsBuildImageProps { * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html */ export class WindowsBuildImage implements IBuildImage { + /** + * Corresponds to the standard CodeBuild image `aws/codebuild/windows-base:1.0`. + * + * @deprecated `WindowsBuildImage.WINDOWS_BASE_2_0` should be used instead. + */ public static readonly WIN_SERVER_CORE_2016_BASE: IBuildImage = new WindowsBuildImage({ imageId: 'aws/codebuild/windows-base:1.0', imagePullPrincipalType: ImagePullPrincipalType.CODEBUILD, }); + /** + * The standard CodeBuild image `aws/codebuild/windows-base:2.0`, which is + * based off Windows Server Core 2016. + */ + public static readonly WINDOWS_BASE_2_0: IBuildImage = new WindowsBuildImage({ + imageId: 'aws/codebuild/windows-base:2.0', + imagePullPrincipalType: ImagePullPrincipalType.CODEBUILD, + }); + /** * @returns a Windows build image from a Docker Hub image. */ diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index 25e6b8d97244f..b2d53df585ca6 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -174,7 +174,6 @@ "docs-public-apis:@aws-cdk/aws-codebuild.Source.gitHubEnterprise", "docs-public-apis:@aws-cdk/aws-codebuild.Source.s3", "docs-public-apis:@aws-cdk/aws-codebuild.StateChangeEvent.currentPhase", - "docs-public-apis:@aws-cdk/aws-codebuild.WindowsBuildImage.WIN_SERVER_CORE_2016_BASE", "docs-public-apis:@aws-cdk/aws-codebuild.WindowsBuildImage.fromDockerRegistry", "docs-public-apis:@aws-cdk/aws-codebuild.WindowsBuildImage.fromEcrRepository", "props-default-doc:@aws-cdk/aws-codebuild.ArtifactsProps.identifier", diff --git a/packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts b/packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts index 28ccb15726815..11ae1fea6ac69 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts @@ -303,7 +303,7 @@ export = { path: 'path/to/source.zip', }), environment: { - buildImage: codebuild.WindowsBuildImage.WIN_SERVER_CORE_2016_BASE, + buildImage: codebuild.WindowsBuildImage.WINDOWS_BASE_2_0, }, }); @@ -442,7 +442,7 @@ export = { }, "Environment": { "ComputeType": "BUILD_GENERAL1_MEDIUM", - "Image": "aws/codebuild/windows-base:1.0", + "Image": "aws/codebuild/windows-base:2.0", "PrivilegedMode": false, "Type": "WINDOWS_CONTAINER" }, @@ -1280,7 +1280,7 @@ export = { 'using ComputeType.Small with a Windows image fails validation'(test: Test) { const stack = new cdk.Stack(); const invalidEnvironment: codebuild.BuildEnvironment = { - buildImage: codebuild.WindowsBuildImage.WIN_SERVER_CORE_2016_BASE, + buildImage: codebuild.WindowsBuildImage.WINDOWS_BASE_2_0, computeType: codebuild.ComputeType.SMALL, };