Skip to content

feat(route53): support restricting delegated zone names when using grantDelegation#35129

Merged
mergify[bot] merged 18 commits intoaws:mainfrom
Kasra-G:ft/route53-grant-delegation-name
Nov 14, 2025
Merged

feat(route53): support restricting delegated zone names when using grantDelegation#35129
mergify[bot] merged 18 commits intoaws:mainfrom
Kasra-G:ft/route53-grant-delegation-name

Conversation

@Kasra-G
Copy link
Copy Markdown
Contributor

@Kasra-G Kasra-G commented Aug 1, 2025

Issue # (if applicable)

Closes #28078.

Reason for this change

Allowing the option to restrict the hosted zone names the delegation role can create records for encourages minimum permissions setup. The linked issue establishes a fairly common usecase - different roles for dev.example.come and prod.example.com,

Description of changes

Adds the interface GrantDelegationOptions, with optional readonly prop delegatedZoneNames. This interface is used as an optional prop to hostedZone.grantDelegation().

Example usage:

declare const zone: IHostedZone
declare const role: Role

zone.grantDelegation(role, {
  delegatedZoneNames: ['a.example.com'],
})

Added some validation that ensures each of the delegatedZoneNames is a valid subdomain of the parent hosted zone.

Additionally, updated the README with usage instructions and fixed an outdated code example for how to use grantDelegation. This code example was giving too broad permissions that what was necessary.

Describe any new or updated permissions being added

when delegatedZoneNames is provided with [a.example.com], the following condition is added:

"ForAllValues:StringEquals": {
 "route53:ChangeResourceRecordSetsRecordTypes": [
  "NS"
 ],
 "route53:ChangeResourceRecordSetsActions": [
  "UPSERT",
  "DELETE"
 ],
+ "route53:ChangeResourceRecordSetsNormalizedRecordNames": [
+  "a.example.com"
+ ]

Description of how you validated changes

Updated Integ and unit tests

Checklist


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

@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Aug 1, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 1, 2025 09:22
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Aug 1, 2025
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

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

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

@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 Aug 1, 2025
Copy link
Copy Markdown
Contributor

@pahud pahud left a comment

Choose a reason for hiding this comment

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

A few minor suggestions for consideration:

  1. Input Validation: Consider adding validation that the provided record names are valid DNS names to catch errors early rather than at IAM policy evaluation time.

  2. Documentation Enhancement: It might be helpful to clarify in the README that the record names should be the actual NS record names that will be created (e.g., for delegating beta.example.com, you'd specify ['beta.example.com']).

  3. Property Naming: While nameEquals is clear, recordNames or allowedRecordNames might be slightly more intuitive for users.

These are minor suggestions - the core implementation is solid. Thanks for contributing this useful feature to the CDK!

@Kasra-G

This comment was marked as outdated.

@jochemd
Copy link
Copy Markdown

jochemd commented Aug 9, 2025

Maybe the property should be named subZones or childZones to reinforce this only grants rights to create NS records.

Update: so according to RFC 9499 DNS Terminology there is no uniform name, but child zone is definitely the most common name.

@Kasra-G

This comment was marked as outdated.

@Kasra-G Kasra-G force-pushed the ft/route53-grant-delegation-name branch from 88ea9b1 to 005bb30 Compare September 2, 2025 03:20
@Kasra-G

This comment was marked as outdated.

@Kasra-G Kasra-G requested a review from pahud September 2, 2025 03:51
@Kasra-G Kasra-G changed the title feat(route53): support specifying record names when using grantDelegation feat(route53): support restricting delegated zone names when using grantDelegation Sep 3, 2025
@Kasra-G
Copy link
Copy Markdown
Contributor Author

Kasra-G commented Sep 9, 2025

Exemption requested for the Security Guardian check - the fix would be to restrict the trust policy on the delegation role to specific role name, but the CrossAccountZoneDelegationRecord does not allow you to specify a role name.

Additionally, the integ test is using conditions to limit access

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Oct 17, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Oct 23, 2025
@Kasra-G
Copy link
Copy Markdown
Contributor Author

Kasra-G commented Nov 3, 2025

Tokens in delegatedZoneNames or the hosted zone name now bypass most validation logic, because if these are things like stack parameters we have no way to validate them.

Additionally we now handle the octal code conversion in the delegated zone name which is something I missed on the first iteration. Names with tokens in them are not encoded.

Characters other than a–z, 0–9, - (hyphen), _ (underscore), and . (period, as a delimiter between labels) must use escape codes in the format \three-digit octal code. For example, \052 is the octal code for character *

@aws-cdk-automation aws-cdk-automation removed the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Nov 3, 2025
Copy link
Copy Markdown
Member

@Abogical Abogical left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!
I've requested another reviewer to sign of on this before merging for next release.

@Abogical Abogical added the pr/requires-two-approvers This PR is critical (e.g., security, broadly-impacting) and requires 2 approvers to be merged. label Nov 3, 2025
@Abogical
Copy link
Copy Markdown
Member

Abogical commented Nov 3, 2025

@Mergifyio update

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 3, 2025

update

❌ Mergify doesn't have permission to update

Details

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/analytics-metadata-updater.yml without workflows permission

Abogical
Abogical previously approved these changes Nov 3, 2025
@Kasra-G
Copy link
Copy Markdown
Contributor Author

Kasra-G commented Nov 6, 2025

Noticed opportunity for a small improvement in the input validation order, went ahead and updated it

Abogical
Abogical previously approved these changes Nov 6, 2025
gasolima
gasolima previously approved these changes Nov 14, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 14, 2025

Thank you for contributing! Your pull request will be automatically updated and merged (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 14, 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

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/integration-test-deployment.yml without workflows permission.

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 stale reviews from Abogical and gasolima November 14, 2025 16:36

Pull request has been modified.

@Abogical Abogical removed the pr/requires-two-approvers This PR is critical (e.g., security, broadly-impacting) and requires 2 approvers to be merged. label Nov 14, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 14, 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
Copy Markdown
Contributor

mergify bot commented Nov 14, 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 d832aca into aws:main Nov 14, 2025
18 of 20 checks passed
@github-actions
Copy link
Copy Markdown
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 Nov 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-route53: restrict domain names in cross-account delegation

6 participants