Skip to content

feat(codebuild): add ec2 image types #34365

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

okasyun
Copy link

@okasyun okasyun commented May 6, 2025

Issue # (if applicable)

Closes #32978.

Reason for this change

The CodeBuild CDK code needs to add new image types to match newly supported environment types: LINUX_EC2, ARM_EC2 and WINDOWS_EC2.

These three imageId values were used because they are the only ones supported when launching EC2-based CodeBuild environments through both CloudFormation and the AWS API. Other image IDs resulted in errors or were not accepted for the LINUX_EC2, WINDOWS_EC2 and ARM_EC2 environment types.

  • LINUX_EC2:aws/codebuild/ami/amazonlinux-x86_64-base:latest
  • ARM_EC2 aws/codebuild/ami/amazonlinux-arm-base:latest
  • WINDOWS_EC2:aws/codebuild/ami/windows-base:2022

Description of changes

Add new image types LINUX_EC2, ARM_EC2 and WINDOWS_EC2 into file.

Description of how you validated changes

I created unit tests and integration tests.
Both were successful.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels May 6, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team May 6, 2025 07:04
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label May 6, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 6, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 7336f4c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@scorbiere scorbiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, I left a couple of questions.

@@ -46,6 +62,13 @@ export class LinuxArmBuildImage implements IBuildImage {
/** Image "aws/codebuild/amazonlinux-aarch64-standard:3.0" based on Amazon Linux 2023. */
public static readonly AMAZON_LINUX_2023_STANDARD_3_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux-aarch64-standard:3.0');

/** The Amazon Linux arm 1.0 AMI, based on Amazon Linux 2023. */
public static readonly AMAZON_LINUX_2023_AMI: IBuildImage = new LinuxArmBuildImage({
imageId: 'aws/codebuild/ami/amazonlinux-arm-base:latest',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help me figure out why :latest is a safe choice?
Information I found is a bit confusing in that regard:

aws codebuild list-curated-environment-images \
  --query 'platforms[].languages[].images[].[name,description] | [?starts_with(@[0], `aws/codebuild/ami/amazonlinux-arm-base`)]'  

output is:

[
    [
        "aws/codebuild/ami/amazonlinux-arm-base:2023-1.0",
        "AWS CodeBuild Reserved Capacity AMI based on Amazon Linux 2023 AMI built by Amazon Web Services (arm64)"
    ],
    [
        "aws/codebuild/ami/amazonlinux-arm-base:latest",
        "AWS CodeBuild On-Demand AMI based on Amazon Linux AMI built by Amazon Web Services (arm64)"
    ]
]

I guess we want to use the On-Demand one even if there is no mention about Amazon Linux 2023? (which might just be a miss in the description).

public static readonly AMAZON_LINUX_2023_AMI: IBuildImage = new LinuxArmBuildImage({
imageId: 'aws/codebuild/ami/amazonlinux-arm-base:latest',
imagePullPrincipalType: ImagePullPrincipalType.CODEBUILD,
imageType: LinuxArmImageType.ARM_EC2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that AMI-based image are meant to be used with EC2, based on this link

An Amazon Machine Image (AMI) is the basic unit of deployment in Amazon EC2, and is one of the types of images you can create with Image Builder. An AMI is a pre-configured virtual machine image that contains the operating system (OS) and preinstalled software to deploy EC2 instances.

Which makes me wonder if we shouldn't add another static method helper like:

  public static fromCodeBuildAmiImageId(id: string): IBuildImage {
    return new LinuxArmBuildImage({
      imageId: id,
      imagePullPrincipalType: ImagePullPrincipalType.CODEBUILD,
      imageType: LinuxArmImageType.ARM_EC2,
    });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-codebuild: missing CodeBuild image types for newly supported environment types
3 participants