aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

aws-batch: documentation gives wrong default for allocation strategy

Open JackDunnNZ opened this issue 2 weeks ago • 1 comments

Describe the issue

On https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.AllocationStrategy.html and other pages, the default allocation strategy is listed as SPOT_CAPACITY_OPTIMIZED if using Spot instances. However, the default was actually changed to SPOT_PRICE_CAPACITY_OPTIMIZED a couple of years ago in https://github.com/aws/aws-cdk/commit/e0ca252acee8290558edddde137458a055ad0b9e and some docs were not updated at that time

Links

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.AllocationStrategy.html

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EcsComputeEnvironment.html#allocationstrategy

Some code links, there may be more:

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L21

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L112

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L263

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L466

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L543

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L818

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L960

JackDunnNZ avatar Dec 09 '25 19:12 JackDunnNZ

Hi @JackDunnNZ,

Thank you for reporting this documentation inconsistency. You're correct - the default allocation strategy was changed from SPOT_CAPACITY_OPTIMIZED to SPOT_PRICE_CAPACITY_OPTIMIZED in PR #26731 back in August 2023, but several JSDoc comments in the source code were not updated at that time.

The actual implementation in determineAllocationStrategy is correct and uses SPOT_PRICE_CAPACITY_OPTIMIZED as the default for Spot instances. The issue is purely in the documentation comments that generate the published API docs.

The fix involves updating the @default JSDoc comments at the locations you identified in managed-compute-environment.ts to reflect the correct default value. This is a good first contribution opportunity if you'd like to submit a PR! The changes would be:

  1. Update all @default comments that mention allocation strategy
  2. Replace SPOT_CAPACITY_OPTIMIZED with SPOT_PRICE_CAPACITY_OPTIMIZED
  3. Ensure consistency across all interfaces (IManagedEc2EcsComputeEnvironment, ManagedEc2EcsComputeEnvironmentProps, IManagedEc2EksComputeEnvironment, ManagedEc2EksComputeEnvironmentProps)

Would you be interested in contributing this fix?

pahud avatar Dec 10 '25 19:12 pahud

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] avatar Dec 19 '25 01:12 github-actions[bot]