Fix: CodeBuild Runner Compute Type and Image Errors
The image and instance-size overrides only work with the exact identifiers CodeBuild publishes. Here is the current list and the syntax.
According to AWS CodeBuild docs, you can override the environment image, instance size, or fleet from the runs-on label, but only with the identifiers CodeBuild supports. A wrong identifier is a common cause of a build that will not start or runs on the wrong environment. This page lists the documented options; verify the current list against the AWS source, as AWS adds and retires images.
The override syntax
According to AWS docs, append overrides to the label, for example: image:<environment-type>-<image-identifier> and instance-size:<size>. For an EC2 build the environment type and image identifier come from the supported-images list; for example image:arm-3.0 with instance-size:small.
Supported EC2 environment types
According to AWS docs, EC2 environment types include linux (image identifiers 4.0 and 5.0), linux-ec2 (latest), arm (2.0 and 3.0), arm-ec2 (latest), ubuntu (5.0, 6.0, 7.0), windows (1.0, 2.0, 3.0), and windows-ec2 (2022). These cover Amazon Linux, Ubuntu, ARM/Graviton, and Windows Server Core platforms.
Instance sizes and GPU
According to AWS docs, instance sizes include small, medium, large, xlarge, and 2xlarge on many Linux images, plus gpu_small and gpu_large on GPU-capable Linux images such as linux 4.0 and ubuntu 5.0. Windows images document medium and large. Use gpu_small or gpu_large when your job needs GPU compute.
Lambda compute images
According to AWS docs, Lambda environment types linux-lambda and arm-lambda support runtime-specific image identifiers (for example nodejs20, python3.12, corretto21, go1.21) with memory sizes 1GB through 10GB. Lambda compute is billed per build-second rather than per build-minute.
Fleet overrides
According to AWS docs, to run on reserved capacity, append fleet:<fleet-name> to the label; you can combine it with an image override. If you provide no image override, CodeBuild uses the image configured on the project, which is how custom images are used.