Closed fogfish closed 2 years ago
Hello @fogfish,
The port
parameter not being required is due to the following, as described in the docs:
If the target is a Lambda function, this parameter does not apply.
Same with Protocol
and VpcId
.
We could add some client-side checks (with exceptions being thrown), but I'm not sure it's possible to do it with types given the current API.
Yes, this is definitely make sense. Thank you for hints! May be similar statement shall be applied to CDK docs https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-elasticloadbalancingv2.ApplicationTargetGroup.html
Feel free to close the issue!
One side comment. I've notice that similar issue is reflected to other Props
. I know it would not be closed as part of this bug report. However, have you considered to declare a narrow Props
that concern a particular use-case. It would make API a typesafe good for developers but of course it would require maintenance from your side. In typescript, this is called 'Discriminated Unions'.
Unfortunately we're not currently allowing type unions, since not all languages we're targeting with jsii support them natively and we haven't narrowed down a way to represent them in those languages.
We can still keep this issue open, even if there is no static checking, there should be runtime validation in the construct so you don't need to wait for a CloudFormation deployment to detect this situation.
Oh... True... TypeScript is not a central language for AWS CDK. I'll wish it will be the only one ;-)
Thank you for feedback!
I can take the PR if no one wants it 👍
I took a look into this, and it looks like the validation method is already there, introduced in #3348:
Since targetType
is not required by the resource, I don't think we can do any additional validation if targetType
is undefined, which is why this becomes an error only when deployed.
Outside of the fact that I'm pretty sure the error message ought to read "Both port and protocol is required" based on the logic, I don't think there's much to do here.
@rix0rrr perhaps you can double check but I think this can just be closed.
Please re-open if you are experiencing this issue
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
ApplicationTargetGroupProps
defines all properties optional. However, it fails at runtime ifport
property is not defined.Reproduction Steps
Error Log
Environment
This is :bug: Bug Report