Describe the bug
It seems like AWS CodeBuild recently added support for SMALL compute type with GPU compute environments (blog post from Mar 17, 2023). CDK CodeBuild seems to have a now-outdated check to ensure only LARGE compute type can be used with GPU instances https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-codebuild/lib/linux-gpu-build-image.ts#L146
which leads to an error if the small GPU codebuild is used:
RuntimeError: Invalid CodeBuild environment: GPU images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_SMALL' was given
For more context on the small GPU compute type support:
- The docs show support for SMALL compute type with GPU environment:

- CodeBuild UI also allows you to specify the build type.

Expected Behavior
CDK users should be allowed to select compute type for BUILD_GENERAL1_SMALL along with a GPU environment now that codebuild does support it.
Current Behavior
An exception is raised:
RuntimeError: Invalid CodeBuild environment: GPU images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_SMALL' was given
It looks like this error comes from CDK code https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-codebuild/lib/linux-gpu-build-image.ts#L146
Reproduction Steps
from aws_cdk import Stack, App, aws_codebuild
from constructs import Construct
class BadBuildEnvironment(Stack):
def __init__(
self,
scope: Construct,
construct_id: str,
**kwargs,
) -> None:
super().__init__(scope, construct_id, **kwargs)
aws_codebuild.BuildEnvironment(
build_image=aws_codebuild.LinuxGpuBuildImage.aws_deep_learning_containers_image(
repository_name="pytorch-training",
tag="1.13.1-gpu-py39-cu117-ubuntu20.04-ec2",
),
compute_type=aws_codebuild.ComputeType.SMALL,
)
BadBuildEnvironment(app, "BadBuildEnvironment")
app.synth()
Then I run
cdk synth BadBuildEnvironment and see:
RuntimeError: Invalid CodeBuild environment: GPU images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_SMALL' was given
Possible Solution
Update the validation to allow for SMALL type since it's now supported on the codebuild side.
Additional Information/Context
No response
CDK CLI Version
2.77.0 (build 06a0b19)
Framework Version
No response
Node.js Version
v20.0.0
OS
Linux HEUWL07705 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Language
Python
Language Version
No response
Other information
No response
Describe the bug
It seems like AWS CodeBuild recently added support for SMALL compute type with GPU compute environments (blog post from Mar 17, 2023). CDK CodeBuild seems to have a now-outdated check to ensure only LARGE compute type can be used with GPU instances https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-codebuild/lib/linux-gpu-build-image.ts#L146
which leads to an error if the small GPU codebuild is used:
For more context on the small GPU compute type support:
Expected Behavior
CDK users should be allowed to select compute type for
BUILD_GENERAL1_SMALLalong with a GPU environment now that codebuild does support it.Current Behavior
An exception is raised:
RuntimeError: Invalid CodeBuild environment: GPU images only support ComputeType 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_SMALL' was given
It looks like this error comes from CDK code https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-codebuild/lib/linux-gpu-build-image.ts#L146
Reproduction Steps
Then I run
cdk synth BadBuildEnvironmentand see:Possible Solution
Update the validation to allow for SMALL type since it's now supported on the codebuild side.
Additional Information/Context
No response
CDK CLI Version
2.77.0 (build 06a0b19)
Framework Version
No response
Node.js Version
v20.0.0
OS
Linux HEUWL07705 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Language
Python
Language Version
No response
Other information
No response