-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(route53): improve constructs for basic records #2741
Conversation
Constructs for basic records (CNAME, TXT, etc.) now extend the `BasicRecord` construct and offer better typed properties interfaces. Add constructs for A, AAAA, CAA, MX and SRV records. Add support for multiple values in basic records. Make `recordName` optional with default to zone root. Add a "security" `CaaAmazonRecord` construct to easily restrict certificate authorities allowed to issue certificates for a domain to Amazon only. BREAKING CHANGE: `recordValue: string` prop in `route53.TxtRecord` changed to `values: string[]` * `recordValue` prop in `route53.CnameRecord` renamed to `domainName`
* | ||
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-basic.html | ||
*/ | ||
export class BasicRecord extends Resource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract class
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not abstract, then it should probably be called RecordSet
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to highlight the fact that it's a construct for Basic Records only (not alias, failover, geolocation, etc. see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values.html).
I don't think it should be abstract, one could use this class to create a record set for record type that is not implemented in an inherited class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. If it mirrors the L1 resource it should have the same name I feel. Shouldn't it be called RecordSet then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could say the same for AliasRecord
looking at its implementation... 🤔
I let you decide...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the current design is probably not great. AliasRecord
shouldn't be a class by itself, but probably ARecord
needs an aliasTarget
property.
Do you have any specific changes in mind you would like to propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, the best solution here would be a base RecordSet
class with aliasTarget
moved to both ARecord
and AaaaRecord
.
Will update accordingly if you're OK with this (requires small changes in aws-ecs-patterns
and aws-route53-targets
also)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We then need a union type in ARecord
right? Whether there are literal targets or an aliasTarget
? We do union classes like so these days:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that?
new ARecord(this, 'IPs', {
zone: myZone,
target: RecordSetTarget.fromIpAddresses('1.2.3.4', '5.6.7.8') // (...ipAddresses: string[])
});
new ARecord(this, 'Alias', {
zone: myZone,
target: RecordSetTarget.fromAlias(new targets.LoadBalancerTarget(myAlb))
});
The ARecord
would then call super()
with either recordValues
or aliasTarget
.
Another solution is to have both ipAddresses
and target
props with a runtime check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I was thinking. The union type is more in line with what we're currently doing.
* | ||
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-basic.html | ||
*/ | ||
export class BasicRecord extends Resource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not abstract, then it should probably be called RecordSet
.
/** | ||
* A record to delegate further lookups to a different set of name servers. | ||
*/ | ||
export class ZoneDelegationRecord extends RecordSet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be renamed to NsRecord
for uniformity? (ZoneDelegation
is the current name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Jonathan :)
Constructs for records (CNAME, TXT, etc.) now extend the
RecordSet
construct andoffer better typed properties interfaces.
Add constructs for A, AAAA, CAA, MX and SRV records.
Add support for multiple values in basic records.
Make
recordName
optional with default to zone root.Add a "security"
CaaAmazonRecord
construct to easily restrict certificate authoritiesallowed to issue certificates for a domain to Amazon only.
BREAKING CHANGE:
recordValue: string
prop inroute53.TxtRecord
changed tovalues: string[]
recordValue
prop inroute53.CnameRecord
renamed todomainName
route53.AliasRecord
has been removed, useroute53.ARecord
orroute53.AaaaRecord
with thetarget
prop.Pull Request Checklist
design
folderBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.