awscdk/v2.179.0/awscdk/awsroute53targets/IAliasRecordTargetProps.go #33534
Unanswered
rogermullerva
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is in reference to https://github.com/aws/aws-cdk-go/blob/awscdk/v2.179.0/awscdk/awsroute53targets/IAliasRecordTargetProps.go#L8
When using awscdk v2.166 we have the following code that works for our golang project:
// Create a r53 record for the new ALB
target := awsroute53.RecordTarget_FromAlias(awsroute53targets.NewLoadBalancerTarget(alb.ApplicationLoadBalancer()))
When attempting to use awscdk v2.176, the awsroute53targets.NewLoadBalancerTarget function seeks a second argument of type IAliasRecordTargetProps. This is defined as an interface. This was a new feature introduced in version 2.173 (refer to https://github.com/aws/aws-cdk/releases?page=2 )
The code example in awsroute53targets.LoadBalancerTarget.go provides the following:
// route53.NewARecord(this, jsii.String("AliasRecord"), &ARecordProps{
// Zone: Zone,
// Target: route53.RecordTarget_FromAlias(
// targets.NewLoadBalancerTarget(lb, map[string]*bool{
// "evaluateTargetHealth": jsii.Boolean(true),
// })),
// })
However, this does not work, as an interface implementation is expected instead of a struct (or a map).
I found that if I give the second argument as simply a var of IAliasRecordTargetProps or nil, then it will compile but doesn't allow for manipulation of the intended value of evaluateTargetHealth.
I tried implementing the interface with a EvaluateTargetHealth() *bool function and passing an instance of that as the argument, which compiles, but fails at unit test runtime with the following:
panic: 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
├── 🛑 Failing value is an object
│ {
│ HostedZone: [Object],
│ VPC: [Object],
│ SecurityGroups: [Array],
│ Subnets: [],
│ AlbName: 'TestAlb',
│ AlbTargetGroupID: 'TestTargetGroup',
│ CertificateArn: 'arn:aws:acm:region:account-id:certificate/certificate-id',
│ Lambdas: [Object],
│ Route53HostedZoneName: 'example.com',
│ Route53AlbRecordName: 'test'
│ }
╰── 🔍 Failure reason(s):
╰─ Value does not have the "$jsii.byref" key [recovered]
Can you please provide a working example in golang? Or is this missing a New function? Or should be a struct rather then an interface? Don't know if this is a defect or I just don't know how to use it
API Name: awsroute53targets.NewLoadBalancerTarget v2.173
Beta Was this translation helpful? Give feedback.
All reactions