Skip to content

Commit

Permalink
feat(codebuild): X-Large Linux compute type (#28642)
Browse files Browse the repository at this point in the history
https://aws.amazon.com/about-aws/whats-new/2024/01/aws-codebuild-x-large-linux-compute-type/

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
watany-dev authored Jan 10, 2024
1 parent a63ef74 commit 7912d88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-codebuild/lib/compute-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum ComputeType {
SMALL = 'BUILD_GENERAL1_SMALL',
MEDIUM = 'BUILD_GENERAL1_MEDIUM',
LARGE = 'BUILD_GENERAL1_LARGE',
X_LARGE = 'BUILD_GENERAL1_XLARGE',
X2_LARGE = 'BUILD_GENERAL1_2XLARGE',
LAMBDA_1GB = 'BUILD_LAMBDA_1GB',
LAMBDA_2GB = 'BUILD_LAMBDA_2GB',
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,8 @@ export class WindowsBuildImage implements IBuildImage {
errors.push('Windows images do not support Lambda compute types');
}

if (buildEnvironment.computeType === ComputeType.SMALL || buildEnvironment.computeType === ComputeType.X2_LARGE) {
const unsupportedComputeTypes = [ComputeType.SMALL, ComputeType.X_LARGE, ComputeType.X2_LARGE];
if (buildEnvironment.computeType !== undefined && unsupportedComputeTypes.includes(buildEnvironment.computeType)) {
errors.push(`Windows images do not support the '${buildEnvironment.computeType}' compute type`);
}
return errors;
Expand Down
18 changes: 18 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,24 @@ test('using ComputeType.Small with a Windows image fails validation', () => {
}).toThrow(/Windows images do not support the 'BUILD_GENERAL1_SMALL' compute type/);
});

test('using ComputeType.XLarge with a Windows image fails validation', () => {
const stack = new cdk.Stack();
const invalidEnvironment: codebuild.BuildEnvironment = {
buildImage: codebuild.WindowsBuildImage.WIN_SERVER_CORE_2019_BASE,
computeType: codebuild.ComputeType.X_LARGE,
};

expect(() => {
new codebuild.Project(stack, 'MyProject', {
source: codebuild.Source.s3({
bucket: new s3.Bucket(stack, 'MyBucket'),
path: 'path',
}),
environment: invalidEnvironment,
});
}).toThrow(/Windows images do not support the 'BUILD_GENERAL1_XLARGE' compute type/);
});

test('using ComputeType.X2Large with a Windows image fails validation', () => {
const stack = new cdk.Stack();
const invalidEnvironment: codebuild.BuildEnvironment = {
Expand Down

0 comments on commit 7912d88

Please sign in to comment.