aws-elasticloadbalancingv2: Missing validation for protocol in the ApplicationTargetGroup construct
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating an ApplicationTargetGroup in AWS CDK without specifying a protocol, the error is not caught at synthesis time. Instead, it only appears during deployment as a runtime error from the Elastic Load Balancing service:
```
Resource handler returned message: "A protocol must be specified (Service: ElasticLoadBalancingV2, Status Code: 400) (SDK Attempt Count: 1)"
```
This results in wasted time and failed deployments, even though the required protocol is a simple, well-defined property that could easily be validated during synthesis.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
The ApplicationTargetGroup construct should validate that the protocol property is specified during synthesis. If missing, CDK should raise a synthesis-time error, preventing failed deployments and improving developer experience.
### Current Behavior
Currently, CDK allows creating a target group without a protocol. The error is only detected during deployment. Example of failing code:
```
this.targetGroup = new ApplicationTargetGroup(this, 'TargetGroup', {
vpc: this.vpc
});
```
The code can be fixed by specifying the protocol:
```
this.targetGroup = new ApplicationTargetGroup(this, 'TargetGroup', {
vpc: this.vpc,
protocol: ApplicationProtocol.HTTPS,
});
```
### Reproduction Steps
N/A
### Possible Solution
Since the protocol property is mandatory for ApplicationTargetGroup, adding validation at synthesis time would prevent runtime errors and save developers from failed deployments.
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.207.0
### AWS CDK CLI version
2.1022.0
### Node.js Version
18.20.2
### OS
MacOS
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start at the ApplicationTargetGroup construct and inspect how its protocol property is currently handled during synthesis. Add coverage for a missing protocol and confirm that synthesis reports the error instead of allowing the deployment-time Elastic Load Balancing failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100