(aws-route53-targets) evaluate_target_health not supported when creating LoadBalancerTarget in Python
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
evaluate_target_health is not correctly supported when using LoadBalancerTarget with RecordTarget.from_alias in the Python CDK.
According to the documentation [1], the following should work:
```python
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(
targets.LoadBalancerTarget(lb, {
"evaluate_target_health": True
})
)
)
```
But get the following error: `RuntimeError: Passed to parameter props of new aws-cdk-lib.aws_route53_targets.LoadBalancerTarget: Unable to deserialize value as aws-cdk-lib.aws_route53_targets.IAliasRecordTargetProps | undefined`
Workaround is to use an escape hatch:
```python3
# Route53 A Record for ALB
self._r53_a_record = route53.ARecord(
self,
"AlbEndpointRecord",
zone=self._hosted_zone,
target=route53.RecordTarget.from_alias(
alias_target=targets.LoadBalancerTarget(alb)
),
delete_existing=False,
record_name=self._hosted_zone_record_name_fqdn,
comment="Application Load Balancer Endpoint A Record",
)
# Escape hatch to set EvaluateTargetHealth to true
cfn_record = self._r53_a_record.node.default_child
cfn_record.add_property_override("AliasTarget.EvaluateTargetHealth", True)
```
1. [AWS CDK Route53 targets docs](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_route53_targets/README.html)
2. [StackOverflow: Alias record for CloudFront distribution](https://stackoverflow.com/questions/64978384/aws-cdk-creating-an-alias-record-for-existing-cloud-front-distribution-in-route)
3. [StackOverflow: Alias of a record in the same hosted zone](https://stackoverflow.com/questions/67623939/aws-cdk-how-can-i-create-an-alias-of-a-record-in-the-same-hosted-zone)
4. [AWS CDK Escape Hatches](https://docs.aws.amazon.com/cdk/v2/guide/cfn-layer.html)
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
Passing evaluate_target_health=True should work and generate a valid CloudFormation AWS::Route53::RecordSet resource with:
```json
"EvaluateTargetHealth": true
```
### Current Behavior
`RuntimeError: Passed to parameter props of new aws-cdk-lib.aws_route53_targets.LoadBalancerTarget: Unable to deserialize value as aws-cdk-lib.aws_route53_targets.IAliasRecordTargetProps | undefined`
### Reproduction Steps
See above
### Possible Solution
Looks to be a JSII documentation issue and no solution was implemented.
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.216.0
### AWS CDK CLI version
2.1029.2
### Node.js Version
v22.15.1
### OS
MacOS
### Language
Python
### Language Version
3.12.8
### Other information
_No response_
Contributor guide
Research direction
Start with the aws_route53_targets.LoadBalancerTarget props and the JSII-generated Python binding, using the reported example as the reproduction. Trace how evaluate_target_health is passed to the alias target and verify that the synthesized AWS::Route53::RecordSet contains AliasTarget.EvaluateTargetHealth set to true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100