Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-route53: Creating a RecordSet with weight of zero throws an Error #29556

Closed
brandonjs opened this issue Mar 20, 2024 · 2 comments · Fixed by #29595 · May be fixed by NOUIY/aws-solutions-constructs#98, NOUIY/aws-solutions-constructs#99 or NOUIY/aws-solutions-constructs#101
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@brandonjs
Copy link

brandonjs commented Mar 20, 2024

Describe the bug

When creating an ARecord object in Route53 with props.weight set to 0 an Error is thrown.

Expected Behavior

The record would be created with weight zero which is a valid value.

Current Behavior

An Error is thrown:

The issue is that when props.weight = 0, !props.weight in Javascript becomes !0 which evaluates as true.

$ node
Welcome to Node.js v18.15.0.
Type ".help" for more information.
> !0
true

Reproduction Steps

Create an ARecord object with weight of zero:

new ARecord(this, "ARecord", {
    zone: publicHostedZone,
    recordName: "myendpoint.example.com,
    target: RecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)),
    weight: 0,
    setIdentifier: "ALB",
});

And run cdk synth.

Possible Solution

Change !props.weight to props.weight === undefined.

Additional Information/Context

Bug introduced in 1.124

CDK CLI Version

^2.132.1

Framework Version

No response

Node.js Version

18.18.2

OS

Any

Language

TypeScript

Language Version

No response

Other information

Error: setIdentifier can only be specified for non-simple routing policies
    at new RecordSet (/redacted/node_modules/aws-cdk-lib/aws-route53/lib/record-set.js:1:3773)
    at new ARecord (/redacted/node_modules/aws-cdk-lib/aws-route53/lib/record-set.js:1:7348)
    at EcsClusterStack.createLoadBalancer (/redacted/dist/lib/stacks/api_service/ecs_cluster.js:126:9)
    at new EcsClusterStack (/redacted/dist/lib/stacks/api_service/ecs_cluster.js:29:34)
    at new ApiService (/redacted/dist/lib/constructs/api_service.js:34:30)
    at addDeploymentGroupsToPipelineStage (/redacted/dist/lib/app.js:200:28)
    at /redacted/dist/lib/app.js:85:9
    at Array.forEach (<anonymous>)
    at /redacted/dist/lib/app.js:84:21
    at Array.forEach (<anonymous>)

Node.js v18.18.2
@brandonjs brandonjs added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Mar 20, 2024
@tim-finnigan tim-finnigan self-assigned this Mar 20, 2024
@tim-finnigan tim-finnigan added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@tim-finnigan
Copy link

Thanks for reporting the issue. I could reproduce the error you referenced when setting weight to 0. Also in the CDK documentation it notes for weight:

This value can be a number between 0 and 255.

@tim-finnigan tim-finnigan added p1 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Mar 20, 2024
@tim-finnigan tim-finnigan removed their assignment Mar 20, 2024
@godwingrs22 godwingrs22 self-assigned this Mar 20, 2024
@mergify mergify bot closed this as completed in #29595 Mar 27, 2024
mergify bot pushed a commit that referenced this issue Mar 27, 2024
### Issue # (if applicable)

Closes #29556 .

### Reason for this change

When creating an ARecord object in Route53 with props.weight set to 0 an Error is thrown.

### Description of changes

Change checks for `weight` to use `weight === undefined` instead of `!weight`

### Description of how you validated changes

- Added a unit test with `weight: 0`
- Updated integ tests to include a record with `weight: 0`

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
3 participants