aws-codebuild: missing support for Windows on-demand environment
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
Attempting to define an AWS CodeBuild project using the `codebuild.WindowsBuildImage.WIN_SERVER_CORE_2022_BASE_3_0` image combined with an on-demand compute type (`codebuild.ComputeType.LARGE`) fails during CDK deployment (`cdk deploy`) in the `ap-northeast-1` (Tokyo) region.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Version
_No response_
### Expected Behavior
It was expected that a recent Windows Server Core 2022 image like `WIN_SERVER_CORE_2022_BASE_3_0` could be used with standard on-demand compute types (e.g., `LARGE`) within CodeBuild, particularly in the supported regions (incl. `ap-northeast-1`).
The documentation or error messages regarding fleet requirements for specific Windows image versions could be clearer.
### Current Behavior
The `cdk deploy` command fails when trying to create the `AWS::CodeBuild::Project` resource with the following error with hitting [this validation](https://github.com/aws/aws-cdk/blob/f2c5f26e134ee32aaf2653e217de56289fcf11f1/packages/aws-cdk-lib/aws-codebuild/lib/project.ts#L2238-L2240):
```
Error: Invalid CodeBuild environment: Windows Server 2022 images must be used with a fleet
at Project.renderEnvironment (/codebuild/output/src00000000/src/actions-runner/_work/MyRepo/.aws-cdk/node_modules/aws-cdk-lib/aws-codebuild/lib/project.js:1:19592)
```
### Reproduction Steps
Use the following minimal CDK TypeScript code:
```typescript
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
export class MinimalErrorReproStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new codebuild.Project(this, 'MinimalWindowsProject', {
environment: {
buildImage: codebuild.WindowsBuildImage.WIN_SERVER_CORE_2022_BASE_3_0,
computeType: codebuild.ComputeType.LARGE,
},
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['echo "Minimal build phase"'],
},
},
}),
source: codebuild.Source.noSource(),
});
}
}
const app = new cdk.App();
new MinimalErrorReproStack(app, 'MinimalCodeBuildErrorStack', {
env: { region: 'ap-northeast-1' }, // Target Tokyo region
});
```
### Possible Solution
Use preserved capacity fleet, which defeats the purpose.
### Additional Information/Context
CodeBuild on-demand Windows environment is available in US East (N. Virginia), US East (Ohio), US West (Oregon), Europe (Ireland), South America (São Paulo), Asia Pacific (Tokyo), Asia Pacific (Sydney), and Europe (Frankfurt).
https://aws.amazon.com/about-aws/whats-new/2025/04/aws-codebuild-on-demand-windows-fleets-4-regions/
### CDK CLI Version
2.1007.0
### Framework Version
2.178.2
### Node.js Version
22
### OS
Ubuntu
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Reproduce the failure with the TypeScript stack in the issue, then inspect packages/aws-cdk-lib/aws-codebuild/lib/project.ts around the linked validation in renderEnvironment. Determine how the Windows Server Core 2022 image and on-demand compute type are represented, and make the supported Tokyo configuration deploy without the fleet error while preserving valid fleet requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- build-system, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100