Skip to content

fix(route53): determineFullyQualifiedDomainName output ends with two periods when hostedzone.zonename is token#20435

Closed
tejasmr wants to merge 10 commits intoaws:mainfrom
tejasmr:tezz-io/route53
Closed

fix(route53): determineFullyQualifiedDomainName output ends with two periods when hostedzone.zonename is token#20435
tejasmr wants to merge 10 commits intoaws:mainfrom
tejasmr:tezz-io/route53

Conversation

@tejasmr
Copy link
Copy Markdown
Contributor

@tejasmr tejasmr commented May 20, 2022


Added forceRemovePeriodProp prop which can forcefully remove the period if desired by the user fixes #20389

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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 May 20, 2022 08:29
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels May 20, 2022
Copy link
Copy Markdown
Contributor

@peterwoodworth peterwoodworth 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 the PR @tezz-io! There are a few things we need to address 🙂

* </ul>
*/
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone): string {
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone, forceRemovePeriodProp?: boolean): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of the name forceRemovePeriodProp - I used that as an example. forceRemovePeriod is fine, but honestly I'm not great at coming up with names. If you have any other suggestions, feel free. Something descriptive like removeDomainNamePeriod is much better in my opinion.

value: 'domain.com.',
exportName: 'zoneNameExample',
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this empty line here, we don't want any empty lines unless they're between the given / when / then clauses


// WHEN
const providedName = 'test';
new cdk.CfnOutput(stack, 'zoneNameExample', {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You shouldn't actually need to create a CfnOutput for the importValue to reference for this test to succeed

* </ul>
*/
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone): string {
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone, forceRemovePeriodProp?: boolean): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function looks great, but this functionality isn't exposed to the user, nor is it being used anywhere where we call this function in the code. So right now, this still isn't doing anything.

This function is called here

name: determineFullyQualifiedDomainName(props.recordName || props.zone.zoneName, props.zone),

It will get used whenever a RecordSet or any of the constructs that extend it are created. So, this option needs to be present for all of those constructs.
We can easily accomplish this by adding the prop to RecordSetOptions
export interface RecordSetOptions {

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented May 24, 2022

@mergify mergify bot dismissed peterwoodworth’s stale review May 24, 2022 05:59

Pull request has been modified.

@tejasmr
Copy link
Copy Markdown
Contributor Author

tejasmr commented May 24, 2022

Hi @peterwoodworth, I fixed all of the issues, but removeDomainNamePeriod was renamed to removeDomainNamePeriodEnd because removeDomainNamePeriod ended with the word period, awslint thought it was of type Duration instead of boolean. I tried with @type annotation but it didn't help. So I renamed the prop to removeDomainNamePeriodEnd. If there is a better name, I will be happy to rename to that. Another alternative was removeDomainNameDot but that didn't seem good.

@tejasmr tejasmr requested a review from peterwoodworth May 24, 2022 10:58
* </ul>
*/
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone): string {
export function determineFullyQualifiedDomainName(providedName: string, hostedZone: IHostedZone, removeDomainNamePeriodEnd?: boolean): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function is interesting.

Is there any scenario the removeDomainNamePeriodEnd should be false with the imported HostedZone?

Copy link
Copy Markdown
Contributor Author

@tejasmr tejasmr May 24, 2022

Choose a reason for hiding this comment

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

If we know the imported hostedZone.zoneName is not a FQDN, e.g., "github.com". If it is ensured that it will be FQDN then with just !Token.isUnresolved(hostedZoneName) condition is enough.

@pahud
Copy link
Copy Markdown
Contributor

pahud commented May 24, 2022

Hi @neilkuan @robertd @misterjoshua

Any comments on this PR? Would love to hear more feedbacks.

@TheRealAmazonKendra TheRealAmazonKendra changed the base branch from v1-main to main June 2, 2022 09:15
Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Looks like our branch change over to v2 caused some branch conflicts. Could you please resolve these?

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review July 14, 2022 06:22

Pull request has been modified.

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

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

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

@peterwoodworth
Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra the issues have been resolved, this is ready for full review. What do you think about this solution?

@TheRealAmazonKendra
Copy link
Copy Markdown
Contributor

@comcalvi and I have been discussing this one and I don't think this is the right solution. We also noted that this is an issue that we have in various contexts so we're looking into a generic larger scale fix.

jogold added a commit to jogold/aws-cdk that referenced this pull request Jul 25, 2022
Because `route53.determineFullyQualifiedDomainName()` doesn't correctly
handles tokens we get the zone name twice here.

Another way to solve this would be to fix
`determineFullyQualifiedDomainName()`. There is already a discussion
there aws#20435 for the hosted zone name
part, not the record name.

Closes aws#21306
@jogold
Copy link
Copy Markdown
Contributor

jogold commented Jul 25, 2022

There's also an issue when the providedName is a token (see #21306 and #21318) because the implementation of determineFullyQualifiedDomainName() checks if it .endsWith('.') which doesn't make sense for a token.

Would be great if this could also be fixed in this PR => fix(route53): incorrect handling of tokens in determineFullyQualifiedDomainName()

@TheRealAmazonKendra
Copy link
Copy Markdown
Contributor

Given that this is not the direction we want to take with this, I'm going to go ahead and close this PR. We can continue the conversation of alternative fixes in the issue. This may require us to make a breaking change and put this under a feature flag but it seems that the impacts of this bug are pretty wide reaching so doing so would likely be worth it to do so.

mergify bot pushed a commit that referenced this pull request Aug 5, 2022
Because `route53.determineFullyQualifiedDomainName()` doesn't correctly
handles tokens we get the zone name twice here.

Another way to solve this would be to fix
`determineFullyQualifiedDomainName()`. There is already a discussion
there #20435 for the hosted zone name
part, not the record name.

Closes #21306


----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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

bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(route53): RecordSetName incorrectly assumes zone name doesn't end with period when hostedzone.zonename is token

6 participants