Open AllanOricil opened 4 months ago
Hey @AllanOricil , thanks for reporting this. From the Read me of conditionequals
, it is apparent as what you are saying is true.
it seems confusing to look at this code inline documentation though as mentioned by you- https://github.com/aws/aws-cdk/blob/5dd72b89f20b1246ad125440e42449acd80c8be7/packages/aws-cdk-lib/core/lib/cfn-fn.ts#L293
I can see this PR was submitted to bring Cloudformation parameter constraint only and it would be helpful to have the clear docs to understand the functionality. Please feel free to submit a PR.
Since this might be a breaking change, I am adding the required labels for Team's input here.
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