diff --git a/packages/aws-cdk-lib/aws-codebuild/lib/environment-type.ts b/packages/aws-cdk-lib/aws-codebuild/lib/environment-type.ts index bcc23e8c3f4e3..dd6df4e6bc417 100644 --- a/packages/aws-cdk-lib/aws-codebuild/lib/environment-type.ts +++ b/packages/aws-cdk-lib/aws-codebuild/lib/environment-type.ts @@ -16,4 +16,10 @@ export enum EnvironmentType { WINDOWS_SERVER_2022_CONTAINER = 'WINDOWS_SERVER_2022_CONTAINER', /** MacOS ARM container */ MAC_ARM = 'MAC_ARM', + /** Linux EC2 */ + LINUX_EC2 = 'LINUX_EC2', + /** ARM EC2 */ + ARM_EC2 = 'ARM_EC2', + /** Windows EC2 */ + WINDOWS_EC2 = 'WINDOWS_EC2', } diff --git a/packages/aws-cdk-lib/aws-codebuild/test/fleet.test.ts b/packages/aws-cdk-lib/aws-codebuild/test/fleet.test.ts index d538541e44a7f..8a9466e5b3807 100644 --- a/packages/aws-cdk-lib/aws-codebuild/test/fleet.test.ts +++ b/packages/aws-cdk-lib/aws-codebuild/test/fleet.test.ts @@ -26,6 +26,78 @@ test('can construct a default fleet', () => { expect(fleet.environmentType).toEqual(codebuild.EnvironmentType.LINUX_CONTAINER); }); +test('can construct a LINUX_EC2 fleet', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const fleet = new codebuild.Fleet(stack, 'Fleet', { + computeType: codebuild.FleetComputeType.SMALL, + environmentType: codebuild.EnvironmentType.LINUX_EC2, + baseCapacity: 1, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Fleet', { + Name: Match.absent(), + BaseCapacity: 1, + ComputeType: 'BUILD_GENERAL1_SMALL', + EnvironmentType: 'LINUX_EC2', + }); + expect(cdk.Token.isUnresolved(fleet.fleetName)).toBeTruthy(); + expect(cdk.Token.isUnresolved(fleet.fleetArn)).toBeTruthy(); + expect(fleet.computeType).toEqual(codebuild.FleetComputeType.SMALL); + expect(fleet.environmentType).toEqual(codebuild.EnvironmentType.LINUX_EC2); +}); + +test('can construct an ARM_EC2 fleet', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const fleet = new codebuild.Fleet(stack, 'Fleet', { + computeType: codebuild.FleetComputeType.SMALL, + environmentType: codebuild.EnvironmentType.ARM_EC2, + baseCapacity: 1, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Fleet', { + Name: Match.absent(), + BaseCapacity: 1, + ComputeType: 'BUILD_GENERAL1_SMALL', + EnvironmentType: 'ARM_EC2', + }); + expect(cdk.Token.isUnresolved(fleet.fleetName)).toBeTruthy(); + expect(cdk.Token.isUnresolved(fleet.fleetArn)).toBeTruthy(); + expect(fleet.computeType).toEqual(codebuild.FleetComputeType.SMALL); + expect(fleet.environmentType).toEqual(codebuild.EnvironmentType.ARM_EC2); +}); + +test('can construct a WINDOWS_EC2 fleet', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const fleet = new codebuild.Fleet(stack, 'Fleet', { + computeType: codebuild.FleetComputeType.MEDIUM, + environmentType: codebuild.EnvironmentType.WINDOWS_EC2, + baseCapacity: 1, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Fleet', { + Name: Match.absent(), + BaseCapacity: 1, + ComputeType: 'BUILD_GENERAL1_MEDIUM', + EnvironmentType: 'WINDOWS_EC2', + }); + expect(cdk.Token.isUnresolved(fleet.fleetName)).toBeTruthy(); + expect(cdk.Token.isUnresolved(fleet.fleetArn)).toBeTruthy(); + expect(fleet.computeType).toEqual(codebuild.FleetComputeType.MEDIUM); + expect(fleet.environmentType).toEqual(codebuild.EnvironmentType.WINDOWS_EC2); +}); + test('can construct a fleet with a specified name', () => { // GIVEN const stack = new cdk.Stack();