Skip to content

aws-codebuild: missing support for Windows on-demand environment #34121

Open
@tsuga

Description

@tsuga

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:

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-codebuildRelated to AWS CodeBuildbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions