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): support geolocation routing #26383

Merged
merged 6 commits into from
Jul 24, 2023
Merged

Conversation

jumic
Copy link
Contributor

@jumic jumic commented Jul 16, 2023

Add support for geolocation routing in Route53 RecordSets.

This PR adds attribute geoLocation to RecordSetOptions and new class GeoLocation. This enables developers to use geolocation routing.

The new feature can be used like this (more examples in README):

new route53.ARecord(this, 'ARecordGeoLocationContinent', {
  zone: myZone,
  target: route53.RecordTarget.fromIpAddresses('1.2.3.0', '5.6.7.0'),
  geoLocation: route53.GeoLocation.continent('EU'), // Europe
});

Closes #9478.


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

@aws-cdk-automation aws-cdk-automation requested a review from a team July 16, 2023 20:34
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Jul 16, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 16, 2023
@colifran colifran self-assigned this Jul 17, 2023
Copy link
Contributor

@laurelmay laurelmay left a comment

Choose a reason for hiding this comment

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

This is really exciting -- it looks like this is the first complex routing supported in the L2 RecordSet construct!

I'm personally really interested in using these APIs and I have a question on the API for continents, some small docs suggestions, and a question about maybe trying to catch a failure case early (during synthesis).

Comment on lines 6 to 13
* Geolocation resource record based on continent code.
* @param continentCode Code of the continent. Valid codes are AF (Africa), AN (Antarctica), AS (Asia),
* EU (Europe), OC (Oceania), NA (North America), SA (South America).
* @returns Continent-based geolocation record
*/
public static continent(continentCode: string) {
return new GeoLocation(continentCode, undefined, undefined);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this has a very small list of acceptable values (and new continents are unlikely), is there value in this being an enum instead?

export enum Continent {
  AFRICA = "AF",
  ANTARCTICA = "AN",
  ASIA = "AS",
  EUROPE = "EU",
  OCEANIA = "OC",
  NORTH_AMERICA = "NA",
  SOUTH_AMERICA = "SA"
}

That way users can do route53.GeoLocation.continent(route53.Continent.ASIA) instead of needing to know the code (and perhaps have autocomplete/suggestions from an IDE/tool)?

It might be a bit overly verbose to do that though, especially since enums aren't really the easiest option for the remaining values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this makes sense. The enum is easier to use. It's not consistent anymore because country uses a string and continent uses an enum. However, I like the autocompletion.

packages/aws-cdk-lib/aws-route53/lib/geo-location.ts Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jul 19, 2023
Copy link
Contributor

@colifran colifran left a comment

Choose a reason for hiding this comment

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

@jumic this looks great! I left a few very minor comments.

@colifran colifran removed their assignment Jul 24, 2023
@mergify mergify bot dismissed colifran’s stale review July 24, 2023 17:38

Pull request has been modified.

Copy link
Contributor

@colifran colifran left a comment

Choose a reason for hiding this comment

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

@jumic Looks great! Thanks for your work and contribution.

@mergify
Copy link
Contributor

mergify bot commented Jul 24, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 6e5b618
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 6bd9a2d into aws:main Jul 24, 2023
5 checks passed
@mergify
Copy link
Contributor

mergify bot commented Jul 24, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this pull request Jul 29, 2023
Add support for [geolocation routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-geo.html) in Route53 RecordSets.

This PR adds attribute `geoLocation` to `RecordSetOptions` and new class `GeoLocation`. This enables developers to use geolocation routing.

The new feature can be used like this (more examples in README):
```ts
new route53.ARecord(this, 'ARecordGeoLocationContinent', {
  zone: myZone,
  target: route53.RecordTarget.fromIpAddresses('1.2.3.0', '5.6.7.0'),
  geoLocation: route53.GeoLocation.continent('EU'), // Europe
});
```

Closes aws#9478.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[route53] Support for geolocation routing
4 participants