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(aws-route53): cross account DNS delegations #12680

Merged
merged 9 commits into from Jan 27, 2021
Merged

feat(aws-route53): cross account DNS delegations #12680

merged 9 commits into from Jan 27, 2021

Conversation

ayush987goyal
Copy link
Contributor

@ayush987goyal ayush987goyal commented Jan 24, 2021

feat(aws-route53): cross account DNS delegations

closes #8776


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 Jan 24, 2021

@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Jan 24, 2021
@ayush987goyal
Copy link
Contributor Author

ayush987goyal commented Jan 24, 2021

Added some tests for the handler but seems like this modules is not migrated to jest yet. Need to see how to make it compatible to jest.

EDIT: Adde usage to nodeunit-shim to migrate tests to jest. Had to skip one test because it was failing from before but was never got caught since it was written in jest.

@ayush987goyal ayush987goyal marked this pull request as ready for review January 25, 2021 17:34
Copy link
Contributor

@njlynch njlynch 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 this PR! Great stuff. I've left a first wave of comments.

@mergify mergify bot dismissed njlynch’s stale review January 26, 2021 16:53

Pull request has been modified.

@ayush987goyal
Copy link
Contributor Author

Hi @njlynch , I have implemented all the suggestions and this PR is ready for the second round.

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the updates!

One minor typo, and one question about one of the tests you fixed (thanks again for the Jest update, btw!)

packages/@aws-cdk/aws-route53/README.md Outdated Show resolved Hide resolved
@ayush987goyal
Copy link
Contributor Author

@njlynch Addressed the comments.

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@mergify
Copy link
Contributor

mergify bot commented Jan 27, 2021

Thank you for contributing! Your pull request will be updated from master 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: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 4b7fd59
  • 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 Jan 27, 2021

Thank you for contributing! Your pull request will be updated from master 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 126a693 into aws:master Jan 27, 2021
@ayush987goyal ayush987goyal deleted the pr/cross-acc-dns branch January 27, 2021 16:16
@OperationalFallacy
Copy link

@ayush987goyal you rock!
I wanted to try it, but it doesn't look like it is in the releases yet? Does cdk have nightly builds or something like that?

@ayush987goyal
Copy link
Contributor Author

@OperationalFallacy Yeah I think this will be release as part of next cut. You might have to wait for it unfortunately :(

@OperationalFallacy
Copy link

OperationalFallacy commented Feb 16, 2021

Hey @ayush987goyal, can this implementation work with cdk-pipeline?
The resources in readme example are created in different accounts and then passed around, but that's not what cdk pipeline can do - it goes and deploys a synth stack in whatever account you tell it to.

https://github.com/aws/aws-cdk/pull/12680/files#diff-8cab009a3f46f19bf8281bf63ebeeeda8a204a2c7a2980ec672f5bb7819795cbR117

What I see the problem of passing NS servers from "sub-zone" account to "parent zone" account now became a problem of passing tld zone id and crossAccountZoneDelegationPrincipal between accounts. Which conceptually is the same problem.

Also, for the delegation role, the trust policy allows "sub-zone" root principal (anybody?) make changes in tld zone? That should be locked to a specific role, but again that goes back to original problem: how to pass something between accounts created in independent stacks.

@ayush987goyal
Copy link
Contributor Author

ayush987goyal commented Feb 17, 2021

Hi @OperationalFallacy ,

The usage of this construct should not actually involve passing the zoneId and role around but to import them using IDs. Dealing with cross account resources has some challenges around with it and for this one you will have to hard code the zoneId and roleArn from the parent account so that they can be imported like so:

const delegationRole = iam.Role.fromRoleArn(this, 'Role', roleArn);

new route53.CrossAccountZoneDelegationRecord(this, 'delegate', {
  delegatedZone: subZone,
  parentHostedZoneId: hostedZoneId,
  delegationRole: delegationRole
});

@njlynch Please add anything else if I missed out or do let me know if we should include such examples in the readme.

@OperationalFallacy
Copy link

Ok, I managed to run it in the pipeline
https://github.com/OperationalFallacy/CdkRouter53/pull/1/files#diff-28e171489876432b7aa1c09d7d1a446d777028d46e763081600b19ead74c9111R12

Imho it is not production ready. The role assume permissions can't be locked to specific entity, only to account root principals.

Another problem is lookups in the pipeline, you're right the zone ID has to be hardcoded since PublicHostedZone.fromLookup would return DUMMY (see #9922)

Putting aside all these technical details for this implementation, I wonder why Cloudformation team can't implement cross-account, cross-region exports so CDK can do what it knows the best?

@McDoit
Copy link
Contributor

McDoit commented Apr 13, 2021

Nice work @ayush987goyal !
Didn't see this PR when I started on mine with #13916
But for sure great synergy there

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Route53] Support for cross account DNS delegation
5 participants