Commit d832aca
authored
feat(route53): support restricting delegated zone names when using grantDelegation (#35129)
### 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:
```ts
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:
```diff
"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
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*1 parent 67b85f2 commit d832aca
File tree
16 files changed
+1987
-55
lines changed- packages
- @aws-cdk-testing/framework-integ/test/aws-route53/test
- integ.zone-delegation-iam-stack.js.snapshot
- asset.2a1e3a5c062d73050b47001ce8443b5cce3002e2af38029f60659b7002ce4b51
- aws-cdk-lib/aws-route53
- lib
- test
16 files changed
+1987
-55
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments