aws-batch: ManagedComputeEnvironment L2's cannot handle CfnParameters due to validations #32905
Labels
@aws-cdk/aws-batch
Related to AWS Batch
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p1
Describe the bug
When attempting to instantiate one of the new L2's for compute environments, synthesis will fail if attempting to use cloud formation parameters for certain configurations. I can work around this with the L1, however it would be nice to be able to use the L2 and skip the client side validation the cdk does for these params. L1 is very tedious and cumbersome for compute environments with lots of properties that can and cannot be specified conditionally depending on others being specified.
I want to be able to do something like this:
maxvCpus: this.SPOT_MAX_VCPU_PARAMETER.valueAsNumber,
but at synthesis the L2 does validations that require the field to be resolved as it does validation that the number is valid.
It would be nice if the validation functions in ManagedComputeEnvironment could check if the values are tokens and if so skip the validation if the construct doesn't need them to be resolved elsewhere. This is done elsewhere in the cdk as there's many issue reports of L2 property validation functions not accounting for the value being a token and some L2's have accepted fixes to bypass if a token.
My use case is such that I have an organization where I'm attempting to build a stack set that creates compute environments in every account, but I want certain configs of that compute environment that created for members of my organization like min and max vcpu.
Regression Issue
Last Known Working CDK Version
N/A
Expected Behavior
Not fail synthesis when passing a CfnParameter token to a ManagedComputeEnvironment L2.
Current Behavior
Synthesis fails due to client side validation of property values passed to the L2 expecting to be resolved.
Reproduction Steps
instantiate a managed compute environment L2 where the minvCpus field takes in a cfn parameter and converts it to number with
.valueAsNumber()
Possible Solution
Potential fix would be to pass the L2's internal validation if the property is a Token. This pattern has been done elsewhere in the cdk in L2 validations so it shouldn't be breaking any design principle if the construct does not depend on it being resolved at synth time. See a similar bug and fix commit for a kinesis config bypassing validation if property is token:
3749c2a
#9038
Additional Information/Context
No response
CDK CLI Version
2.175.1
Framework Version
No response
Node.js Version
22
OS
macOS
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: