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

feat(route53): improve constructs for basic records #2741

Merged
merged 7 commits into from
Jun 7, 2019

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Jun 4, 2019

Constructs for records (CNAME, TXT, etc.) now extend the RecordSet 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
  • route53.AliasRecord has been removed, use route53.ARecord or route53.AaaaRecord with the target prop.

Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

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

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`
@jogold jogold requested a review from a team as a code owner June 4, 2019 15:28
*
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-basic.html
*/
export class BasicRecord extends Resource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract class?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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...

Copy link
Contributor

@rix0rrr rix0rrr Jun 5, 2019

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?

Copy link
Contributor Author

@jogold jogold Jun 5, 2019

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)

Copy link
Contributor

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:

https://github.com/awslabs/aws-cdk/blob/master/packages/@aws-cdk/aws-stepfunctions/lib/input.ts

Copy link
Contributor Author

@jogold jogold Jun 5, 2019

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.

Copy link
Contributor

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 {
Copy link
Contributor

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.

packages/@aws-cdk/aws-route53/lib/records/basic.ts Outdated Show resolved Hide resolved
/**
* A record to delegate further lookups to a different set of name servers.
*/
export class ZoneDelegationRecord extends RecordSet {
Copy link
Contributor Author

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)

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jonathan :)

@rix0rrr rix0rrr merged commit 696f53f into aws:master Jun 7, 2019
@jogold jogold deleted the r53-basic-records branch June 13, 2019 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants