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

docs(route53): crossaccountrole scope-down guidance #28624

Merged
merged 8 commits into from
Jan 10, 2024
40 changes: 34 additions & 6 deletions packages/aws-cdk-lib/aws-route53/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ new route53.ARecord(this, 'ARecord', {
### Cross Account Zone Delegation

If you want to have your root domain hosted zone in one account and your subdomain hosted
zone in a diferent one, you can use `CrossAccountZoneDelegationRecord` to set up delegation
zone in a different one, you can use `CrossAccountZoneDelegationRecord` to set up delegation
between them.

In the account containing the parent hosted zone:
Expand All @@ -192,11 +192,39 @@ const parentZone = new route53.PublicHostedZone(this, 'HostedZone', {
zoneName: 'someexample.com',
});
const crossAccountRole = new iam.Role(this, 'CrossAccountRole', {
// The role name must be predictable
roleName: 'MyDelegationRole',
// The other account
assumedBy: new iam.AccountPrincipal('12345678901'),
});
// The role name must be predictable
Copy link
Contributor

Choose a reason for hiding this comment

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

the formatting here is inconsistent with the rest of the doc in terms of tabs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow, I see other comments in the doc follow the tab alignment of the line of code below it that it speaks to. Can you clarify?

Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-01-09 at 3 26 23 PM

here is your rich diff. the tab alignment is off

roleName: 'MyDelegationRole',
// The other account
assumedBy: new iam.AccountPrincipal('12345678901'),
// You can scope down this role policy to be least privileged.
// If you want the other account to be able to manage specific records,
// you can scope down by resource and/or normalized record names
inlinePolicies: {
"crossAccountPolicy": new iam.PolicyDocument({
statements: [
new iam.PolicyStatement({
sid: "ListHostedZonesByName",
effect: iam.Effect.ALLOW,
actions: ["route53:ListHostedZonesByName"],
resources: ["*"]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i want a comma here and in all other places that should have punctuation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, should be resolved.

}),
new iam.PolicyStatement({
sid: "GetHostedZoneAndChangeResourceRecordSet",
effect: iam.Effect.ALLOW,
actions: ["route53:GetHostedZone", "route53:ChangeResourceRecordSet"],
// This example assumes the RecordSet subdomain.somexample.com
// is contained in the HostedZone
resources: ["arn:aws:route53:::hostedzone/HZID00000000000000000"],
conditions: {
"ForAllValues:StringLike": {
"route53:ChangeResourceRecordSetsNormalizedRecordNames": [
"subdomain.someexample.com"
]

}
}
})
});
parentZone.grantDelegation(crossAccountRole);
```

Expand Down
Loading