Skip to content

aws_route53: Allow more fields from lower level construct (CfnRecordSet) into higher level Record constructs #26753

@christow-aws

Description

@christow-aws

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-route53Related to Amazon Route 53effort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions