Skip to content

Conversation

@vicheey
Copy link
Contributor

@vicheey vicheey commented Dec 2, 2025

Issue #, if available

#3855

Description of changes

  • Fixed CapacityProvider generator to properly handle None values in ScalingConfig and InstanceRequirements
  • Changed dictionary membership checks from in operator to .get() method with explicit None checks
  • Updated ScalingConfig serialization in sam_resources.py to use exclude_none=True parameter
  • This ensures that when only MaxVCpuCount is specified (without AverageCPUUtilization), the ScalingMode correctly defaults to "Auto" instead of incorrectly setting "Manual" with null target values

Description of how you validated changes

  • Added two new test cases (CapacityProviderTwo and PartialCapacityProviderThree) to capacity_provider_full.yaml
    • CapacityProviderTwo tests ScalingConfig with only AverageCPUUtilization (no MaxVCpuCount) → generates ScalingMode: "Manual"
    • PartialCapacityProviderThree tests ScalingConfig with only MaxVCpuCount (no AverageCPUUtilization) → generates ScalingMode: "Auto"
  • Verified generated CloudFormation templates across all partitions (aws, aws-cn, aws-us-gov) correctly set ScalingMode and exclude unspecified properties
  • All transform tests pass with correct output

Checklist

  • Review the generative AI contribution guidelines
  • Adheres to the development guidelines
  • Add/update transform tests
    • Using correct values
    • Using wrong values
  • Add/update integration tests

Examples?

Before this fix:

# SAM Template
Resources:
  MyCapacityProvider:
    Type: AWS::Serverless::CapacityProvider
    Properties:
      ScalingConfig:
        MaxVCpuCount: 10
        # AverageCPUUtilization intentionally omitted - should use Auto scaling

Generated CloudFormation would incorrectly produce:

"CapacityProviderScalingConfig": {
  "MaxVCpuCount": 10,
  "ScalingMode": "Manual",  // ❌ Wrong! Should be "Auto"
  "ScalingPolicies": [] // ❌ Wrong! Should not be included 
}

After this fix:

"CapacityProviderScalingConfig": {
  "MaxVCpuCount": 10,
  "ScalingMode": "Auto"  // ✅ Correct! Auto scaling when no CPU target specified
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vicheey vicheey requested a review from a team as a code owner December 2, 2025 21:38
@vicheey vicheey merged commit 2959621 into develop Dec 3, 2025
7 checks passed
@vicheey vicheey deleted the fix-lmi-scaling-config branch December 3, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants