Skip to content

Conversation

tttol
Copy link
Contributor

@tttol tttol commented Apr 29, 2025

Issue # (if applicable)

N/A

Reason for this change

The L2 construct of Route 53 resource record set did not have a property cidrRoutingConfig. It was always necessary to set this prop via the L1 Construct when configuring IP-based routing.

Description of changes

  • added cidrRoutingConfig to RecordSetProps
  • fixed logic in RecordSet constructor

Describe any new or updated permissions being added

None

Description of how you validated changes

I added new unit test and integration test.

  • cidr-routing-config.test.ts
  • integ.cidr-routing-config.ts

Checklist


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 April 29, 2025 21:21
@github-actions github-actions bot added p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Apr 29, 2025
@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 May 2, 2025
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

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

Thank you for your quick response. I've added some comments and I'll approve this later.

new IntegTest(app, 'CidrRoutingConfigInteg', {
testCases: [stack],
});
app.synth();
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this line.


```ts
declare const zone: route53.HostedZone;

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a example of default cidr config??

if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) {
throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`);
}
if (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take care of the case that location name is a token.

/**
* The object that is specified in resource record set object when you are linking a resource record set to a CIDR location.
*
* A LocationName with an asterisk “*” can be used to create a default CIDR record. CollectionId is still required for default record.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is not needed now by adding default factory method.

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 think this line is needed. There are 2 reasons:

  1. The official documentation for AWS::Route53::RecordSet CidrRoutingConfig includes this explanation.
  2. While the default method now correctly sets locationName to *, I think it would be helpful to explicitly write this requirement for default CIDR records. How do you think?

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 6, 2025
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

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

Thank you for addressing my comments. This is the final request.

if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) {
throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`);
}
if (!Token.isUnresolved(props.locationName) && !props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think regex validation must be executed only when token is resolved.

Suggested change
if (!Token.isUnresolved(props.locationName) && !props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) {
if (!Token.isUnresolved(props.locationName) && (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName))) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

accepted your suggestion and updated unit test.
43a8858

Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

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

Thanks!

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 7, 2025
Copy link
Contributor

@scorbiere scorbiere left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @tttol
I don't see any big blocker but I would like some clarifications (see my other comments). Thank you.

/**
* Creates a new instance of CidrRoutingConfig
*/
public static new(props: CidrRoutingConfigProps): CidrRoutingConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't use new for that method name, especially since it is a commonly used keyword. I would much prefer something like create if we really want to use a static factory strategy.

Suggested change
public static new(props: CidrRoutingConfigProps): CidrRoutingConfig {
public static create(props: CidrRoutingConfigProps): CidrRoutingConfig {

*/
readonly locationName: string;

private constructor(props: CidrRoutingConfigProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious why you are making this constructor private to enforce the utilization of the static factory methods?

Copy link
Contributor Author

@tttol tttol May 10, 2025

Choose a reason for hiding this comment

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

I think private constructor has several benefits:

  1. It centralizes instance creation logic ensuring that all objects are constructed in a consistent and controlled manner.
  2. It allows for the implementation of specialized static methods, such as withDefaultLocationName

In addition, I followed the approach used in the GeoLocation class (a property of RecordSetOptions), which also uses a private constructor.

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-route53/lib/geo-location.ts#L72

private constructor(readonly continentCode: Continent | undefined, readonly countryCode: string | undefined,
    readonly subdivisionCode: string | undefined) {

/**
* The CIDR collection location name.
*/
readonly locationName: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you mark it as optional, you would be able to default it to '*', right?

Copy link
Contributor Author

@tttol tttol May 10, 2025

Choose a reason for hiding this comment

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

Yes, we can default it to '*' if it's optional. I have updated locationName to be an optional property.

  /**
   * The CIDR collection location name.
   */
   readonly locationName?: string;

@scorbiere scorbiere self-assigned this May 9, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 9, 2025
@mergify mergify bot dismissed scorbiere’s stale review May 10, 2025 02:52

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 10, 2025
scorbiere
scorbiere previously approved these changes May 12, 2025
Copy link
Contributor

@scorbiere scorbiere left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all my comments and your contribution :)

@mergify
Copy link
Contributor

mergify bot commented May 12, 2025

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

@mergify
Copy link
Contributor

mergify bot commented May 12, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated.

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify mergify bot dismissed scorbiere’s stale review May 12, 2025 16:21

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented May 12, 2025

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

@mergify mergify bot merged commit 5cd82f5 into aws:main May 12, 2025
16 of 17 checks passed
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member valued-contributor [Pilot] contributed between 6-12 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants