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: Allow more fields from lower level construct (CfnRecordSet) into higher level Record constructs #26753

Closed
1 of 2 tasks
christow-aws opened this issue Aug 14, 2023 · 2 comments · Fixed by #28705 · May be fixed by stack-spot/app-handler-functions-template#2, stack-spot/eks-env-ts-template#2 or stack-spot/web-react-deploy#4
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@christow-aws
Copy link

Describe the feature

When working with constructs such as ARecord, we cannot use a weighted routing policy directly from the construct props. Instead, we have to do something hacky like this:

const aRecord = new ARecord(this, 'RecordSet', {
    target: RecordTarget.fromAlias(new ApiGatewayDomain(domain)),
    zone: hostedZone,
})

const recordSet = aRecord.node.defaultChild as CfnRecordSet
recordSet.weight = 100
recordSet.setIdentifier = 'API-Gateway-A-Record-whatever'

It'd be nice for there to be some sort of solution here that doesn't involve downcasting and knowledge of the guts of this construct to properly hack around.

Use Case

Weighted records of all types for route 53.

Proposed Solution

Not sure how useful this will be for someone who's actually going to do the work...

Since routing policies are mutually exclusive, perhaps some tagged union magic on a new "routing" field would help. For example:

(basically implement these routing policies from AWS' docs)

interface SimpleRoutingPolicy { }

interface WeightedRoutingPolicy {
    // Something between 0-255, per R53 spec
    weight: number
    // The other required and optional fields that I CBA to enumerate
    ...
}

interface ADifferentRoutingPolicy {
  ...
}

type Route53RoutingPolicy = SimpleRoutingPolicy | WeightedRoutingPolicy | ADifferentRoutingPolicy

// stealing from https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.CnameRecordProps.html
interface CnameRecordProps {
    // Stuff that's already there, and should stay
    domainName: string
    zone: IHostedZone
    comment?: string
    deleteExisting?: boolean
    recordName?: string
    ttl?: Duration
    // Move to a GeoLocationRoutingPolicy interface, add that to Route53RoutingPolicy
    geoLocation?: GeoLocation
    // the new "routingPolicy" field
    routingPolicy: Route53RoutingPolicy
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2, TypeScript

Environment details (OS name and version, etc.)

AL2 on x86

@christow-aws christow-aws added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2023
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Aug 14, 2023
@pahud
Copy link
Contributor

pahud commented Aug 14, 2023

Yes I think we could at least expose the weight property in the RecordSetOptions.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2023
@mergify mergify bot closed this as completed in #28705 Jan 17, 2024
mergify bot pushed a commit that referenced this issue Jan 17, 2024
In this PR, I have implemented support for weighted routing. 
By passing the `weight` and `setIdentifier` parameters when registering a record, it is possible to perform weighted routing among records that share the same name and type.

```ts
new route53.ARecord(this, `WeightedRecord${index}`, {
        zone: hostedZone,
        recordName: 'www',
        weight: 20, // added
        setIdentifier: 'uniqueId', // added
        target: route53.RecordTarget.fromIpAddresses('1.2.3.4'),
      });
```

Closes #26753.

----

*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 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
2 participants