Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codebuild): add new environment types #32729

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/lib/environment-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
72 changes: 72 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/test/fleet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading