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

aws-route53: (BREAKING!) Imported Route53 zone attribute and/or type mismatch #26872

Closed
einstein-aws opened this issue Aug 24, 2023 · 9 comments · Fixed by #26888
Closed

aws-route53: (BREAKING!) Imported Route53 zone attribute and/or type mismatch #26872

einstein-aws opened this issue Aug 24, 2023 · 9 comments · Fixed by #26888
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@einstein-aws
Copy link

Describe the bug

Seems like after the latest CDK update to v2.93.0 I am having trouble with importing Route53 hosted zones. I tried:

const route53Zone = r53.HostedZone.fromLookup(this, 'my-route53-zone', { domainName: 'mydomain.com' });

and...

const route53Zone = r53.PublicHostedZone.fromLookup(this, 'my-route53-zone', { domainName: 'mydomain.com' });

and...

const route53Zone = r53.HostedZone.fromHostedZoneAttributes(this, 'my-route53-zone', { zoneName: 'mydomain.com', hostedZoneId: 'my-zone-id' });

and...

const route53Zone = r53.PublicHostedZone.fromHostedZoneAttributes(this, 'my-route53-zone', { zoneName: 'mydomain.com', hostedZoneId: 'my-zone-id' });

and when I tried:

const sesIdentity = ses.Identity.publicHostedZone(route53Zone);

I am getting:

Argument of type 'IHostedZone' is not assignable to parameter of type 'IPublicHostedZone'.
  Property 'grantDelegation' is missing in type 'IHostedZone' but required in type 'IPublicHostedZone'.ts(2345)
hosted-zone.d.ts(146, 5): 'grantDelegation' is declared here.

Expected Behavior

Either of the above imports should work.

Current Behavior

Getting error:

Argument of type 'IHostedZone' is not assignable to parameter of type 'IPublicHostedZone'.
  Property 'grantDelegation' is missing in type 'IHostedZone' but required in type 'IPublicHostedZone'.ts(2345)
hosted-zone.d.ts(146, 5): 'grantDelegation' is declared here.

Reproduction Steps

Try to use either of the above Route53 zone imports in:

const sesIdentity = ses.Identity.publicHostedZone(route53Zone);

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

v2.93.0

Framework Version

No response

Node.js Version

v18.12.0

OS

MacOS Ventura 13.4.1

Language

Typescript

Language Version

No response

Other information

No response

@einstein-aws einstein-aws added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 24, 2023
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Aug 24, 2023
@einstein-aws einstein-aws changed the title route53: (BREAKING!) Imported Route53 zone attribute and/or type mismatch aws-route53: (BREAKING!) Imported Route53 zone attribute and/or type mismatch Aug 24, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 24, 2023
@khushail
Copy link
Contributor

Hi @einstein-aws , could you please share the complete code snippet for reproducing this issue? TIA.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 24, 2023
@khushail khushail self-assigned this Aug 24, 2023
@einstein-aws
Copy link
Author

Hi @khushail. This is literally the code I am using. Here is the excerpt from my stack:

    // Lookup default Route53 public hosted zone
    // const appR53ZoneIdDefault = ssm.StringParameter.valueForStringParameter(this, appLabelR53ZoneIdDefault);
    // const appR53ZoneDefault = r53.PublicHostedZone.fromHostedZoneAttributes(this, appLabelR53Zone, { zoneName: appDomain, hostedZoneId: appR53ZoneIdDefault });
    const appR53Zone        = r53.HostedZone.fromLookup(this, appLabelR53Zone, { domainName: appDomain });
    const appR53SesIdentity = ses.Identity.publicHostedZone(appR53Zone); // <-- error is here

    // Define default SES identity
    const appSesIdentity = new ses.EmailIdentity(this, appLabelSesIdentity, {
      mailFromDomain              : `${appSubDomainMail}.${appDomain}`,
      configurationSet            : appSesConfigurationSet,
      identity                    : appR53SesIdentity,
      mailFromBehaviorOnMxFailure : ses.MailFromBehaviorOnMxFailure.REJECT_MESSAGE,
      dkimSigning                 : true,
      feedbackForwarding          : true
    });
Screenshot 2023-08-24 at 11 30 21 AM

@khushail
Copy link
Contributor

Hi @einstein-aws , I used one of the import methods and tried to reproduce the issue but my code is succeeding. Please see here-
Screenshot 2023-08-24 at 11 51 00 AM

@einstein-aws
Copy link
Author

I am getting the same error no matter what export method I use... Here is my version of your example:

Screenshot 2023-08-24 at 12 39 39 PM

Same problem. What else could it be? I have all my libraries updated (i.e. npm-check-updates).

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 24, 2023
@khushail
Copy link
Contributor

khushail commented Aug 24, 2023

@einstein-aws , the r53.HostedZone.fromLookup(this, appLabelR53Zone, ...) this appLabelR53Zone should be id , while it seems you have given some PublicHostedZone object here. Could you please check again and try giving it some string based id?

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. guidance Question that needs advice or information. and removed bug This issue is a bug. labels Aug 24, 2023
@einstein-aws
Copy link
Author

@khushail It is a string, just a label. But, here is a hardcoded string:

Screenshot 2023-08-24 at 2 07 45 PM

...and here is import using fromHostedZoneId():

Screenshot 2023-08-24 at 2 09 04 PM

@khushail
Copy link
Contributor

khushail commented Aug 24, 2023

@einstein-aws , Yes, you are correct (my bad, forgot to check the version changes). This is a change in the latest version which was released yesterday. Looking at this PR, it looks like the changes in aws-route53 module caused this error.

Marking this issue as P2. Community PRs are welcome.

@khushail khushail added bug This issue is a bug. p2 and removed guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 24, 2023
@khushail khushail removed their assignment Aug 24, 2023
@khushail khushail added the effort/small Small work item – less than a day of effort label Aug 24, 2023
@einstein-aws
Copy link
Author

@khushail Thank you! I hope this will be fixed soon :)

@khushail khushail added effort/medium Medium work item – several days of effort and removed effort/small Small work item – less than a day of effort labels Aug 24, 2023
mergify bot added a commit to lpizzinidev/aws-cdk that referenced this issue Aug 25, 2023
@mergify mergify bot closed this as completed in #26888 Aug 25, 2023
mergify bot pushed a commit that referenced this issue Aug 25, 2023
…dZone anymore (#26888)

`Identity.publicHostedZone` takes an `IPublicHostedZone`, but because of TypeScript structural typing it would also accept an `IHostedZone`. 

When in [this PR](#26333) the `grantDelegation` method was added to the `IPublicHostedZone` interface, this passing was no longer allowed and code that used to work on accident, no longer works.

For example:
```
const zone = HostedZone.fromHostedZoneId(stack, 'Zone', 'hosted-id');
const sesIdentity = ses.Identity.publicHostedZone(zone);
```

It raises an error because the imported `zone` does not implement the `grantDelegation` method.

This fix moves the `grantDelegation` method declaration into the `IHostedZone` interface and makes it available to all imported zones.

Closes #26872.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
2 participants