Skip to content

Commit

Permalink
feat(codebuild): add support for `aws/codebuild/amazonlinux2-aarch64-…
Browse files Browse the repository at this point in the history
…standard:3.0` (#25351)

This fix adds support for `aws/codebuild/amazonlinux2-aarch64-standard:3.0` as added [here](https://github.com/aws/aws-codebuild-docker-images/releases/tag/23.04.25).

Closes #25334.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
lpizzinidev committed Apr 28, 2023
1 parent ad71026 commit 0d187c1
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class LinuxArmBuildImage implements IBuildImage {
public static readonly AMAZON_LINUX_2_STANDARD_1_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-aarch64-standard:1.0');
/** Image "aws/codebuild/amazonlinux2-aarch64-standard:2.0". */
public static readonly AMAZON_LINUX_2_STANDARD_2_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-aarch64-standard:2.0');
/** Image "aws/codebuild/amazonlinux2-aarch64-standard:3.0". */
public static readonly AMAZON_LINUX_2_STANDARD_3_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-aarch64-standard:3.0');

/**
* Returns an ARM image running Linux from an ECR repository.
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,8 @@ export class LinuxBuildImage implements IBuildImage {
* @deprecated Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0 instead.
* */
public static readonly AMAZON_LINUX_2_ARM_2 = LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0;
/** @deprecated Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0 instead. */
public static readonly AMAZON_LINUX_2_ARM_3 = LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0;

/** @deprecated Use `STANDARD_2_0` and specify runtime in buildspec runtime-versions section */
public static readonly UBUNTU_14_04_BASE = LinuxBuildImage.codeBuildImage('aws/codebuild/ubuntu-base:14.04');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,84 @@ describe('Linux ARM build image', () => {
});
});

describe('AMAZON_LINUX_2_STANDARD_3_0', () => {
test('has type ARM_CONTAINER and default ComputeType LARGE', () => {
const stack = new cdk.Stack();
new codebuild.PipelineProject(stack, 'Project', {
environment: {
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
},
});

Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Type: 'ARM_CONTAINER',
ComputeType: 'BUILD_GENERAL1_LARGE',
},
});
});

test('can be used with ComputeType SMALL', () => {
const stack = new cdk.Stack();
new codebuild.PipelineProject(stack, 'Project', {
environment: {
computeType: codebuild.ComputeType.SMALL,
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
},
});

Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Type: 'ARM_CONTAINER',
ComputeType: 'BUILD_GENERAL1_SMALL',
},
});
});

test('cannot be used in conjunction with ComputeType MEDIUM', () => {
const stack = new cdk.Stack();

expect(() => {
new codebuild.PipelineProject(stack, 'Project', {
environment: {
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
computeType: codebuild.ComputeType.MEDIUM,
},
});
}).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/);
});

test('can be used with ComputeType LARGE', () => {
const stack = new cdk.Stack();
new codebuild.PipelineProject(stack, 'Project', {
environment: {
computeType: codebuild.ComputeType.LARGE,
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
},
});

Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Type: 'ARM_CONTAINER',
ComputeType: 'BUILD_GENERAL1_LARGE',
},
});
});

test('cannot be used in conjunction with ComputeType X2_LARGE', () => {
const stack = new cdk.Stack();

expect(() => {
new codebuild.PipelineProject(stack, 'Project', {
environment: {
buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0,
computeType: codebuild.ComputeType.X2_LARGE,
},
});
}).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/);
});
});

describe('ECR Repository', () => {
test('allows creating a build image from a new ECR repository', () => {
const stack = new cdk.Stack();
Expand Down

0 comments on commit 0d187c1

Please sign in to comment.