cdk.Fn: improve conditionEquals parameters types #30036
Labels
@aws-cdk/core
Related to core CDK functionality
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
Because
cdk.Fn.conditionEquals
is expecting 2 parameters of typeany
people can logically think that the following condition, which compares "string" with "string", should work
However, it does not. The proper way to configure this condition is to pass
CfnParameter
reference as follows,which leads to this template piece:
At first, this behavior seems illogical, because:
when reading a code that isn't using
asValueString
, the comparison is clearly between "CfnParameter" and "string" types, which, because of the lack of proper type definition for parameters, won't be considered as an optionthe types in the
conditionEquals
method are of "any", which can make people think that they must compare similar types, like string and string, boolean and boolean, or even CfnParameter to CfnParameter. However, as shown previously, when using the type CfnParameters, the first argument must be its reference and not itsvalueAsString
.Use Case
Developers will clearly know what types can be compared in
cdk.Fn.conditionEquals
when writting or reading code, which improves DX, and therefore efficiency.Proposed Solution
Add all type permutations that are possible for those 2 parameters in
cdk.Fn.conditionEquals
Other Information
No response
Acknowledgements
CDK version used
2.138
Environment details (OS name and version, etc.)
macos
The text was updated successfully, but these errors were encountered: