Skip to content

Commit

Permalink
chore(codebuild): supports a X-Large Linux compute type
Browse files Browse the repository at this point in the history
  • Loading branch information
watany-dev committed Jan 10, 2024
1 parent a63ef74 commit 9f4e8de
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 9f4e8de

Please sign in to comment.