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): add support for grantDelegation on imported PublicHostedZone #26333

Merged
merged 10 commits into from
Aug 18, 2023

Conversation

lpizzinidev
Copy link
Contributor

Imported PublicHostedZone with fromPublicHostedZoneId and fromPublicHostedZoneAttributes don't have support for the grantDelegation method since they return an instance of type IPublicHostedZone.

This change adds support for grantDelegation to those instances as well.

Closes #26240.


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

@gitpod-io
Copy link

gitpod-io bot commented Jul 12, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team July 12, 2023 08:37
@github-actions github-actions bot added star-contributor [Pilot] contributed between 25-49 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jul 12, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review July 17, 2023 07:30

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

We need the build to succeed before giving more thought to the review. The build was failing because the API had changed and these changes will likely fix that. Thanks!

@@ -264,6 +269,9 @@ export class PublicHostedZone extends HostedZone implements IPublicHostedZone {
public get hostedZoneArn(): string {
return makeHostedZoneArn(this, this.hostedZoneId);
}
public grantDelegation(grantee: iam.IGrantable) {
makeGrantDelegation(grantee, this.hostedZoneArn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you need to return makeGrantDelegation

@@ -284,6 +292,9 @@ export class PublicHostedZone extends HostedZone implements IPublicHostedZone {
public get hostedZoneArn(): string {
return makeHostedZoneArn(this, this.hostedZoneId);
}
public grantDelegation(grantee: iam.IGrantable) {
makeGrantDelegation(grantee, this.hostedZoneArn);
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

});

return g1.combine(g2);
makeGrantDelegation(grantee, this.hostedZoneArn);
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

@@ -69,3 +70,24 @@ export function makeHostedZoneArn(construct: Construct, hostedZoneId: string): s
resourceName: hostedZoneId,
});
}

export function makeGrantDelegation(grantee: iam.IGrantable, hostedZoneArn: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please specify the return type in the function definition (looks like iam.Grant or iam.IGrantable)

@mergify mergify bot dismissed scanlonp’s stale review July 25, 2023 08:48

Pull request has been modified.

@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 25, 2023
Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

All of the code looks good. Small nit: we should either move the code to the existing associated cross account delegation integ test, or change the name to take route53 out of the test name to be consistent with the other integ tests.

Comment on lines 10 to 15
const role = new iam.Role(stack, 'Role', {
assumedBy: new iam.AccountRootPrincipal(),
});

const publicZone = PublicHostedZone.fromPublicHostedZoneId(stack, 'PublicZone', 'public-zone-id');
publicZone.grantDelegation(role);
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 we can move these lines of code into the cross-account-zone-delegation integ test, unless you thought about this and had a reason for keeping it separate.

Maybe the name could to shift to const importedPublicZone = PublicHostedZone.from...

Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

Thanks!

@mergify
Copy link
Contributor

mergify bot commented Aug 18, 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 aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 18, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 18, 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: f7f1898
  • 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 a93af2f into aws:main Aug 18, 2023
8 checks passed
@mergify
Copy link
Contributor

mergify bot commented Aug 18, 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).

mergify bot pushed a commit that referenced this pull request 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(route53): Support grantDelegation on imported PublicHostedZone
3 participants