forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route53): New Route53 CrossAccountRecordSet construct
\### Issue # (if applicable) Closes aws#15213 Addresses aws#26754 \### Reason for this change \### Description of changes \### Description of how you validated changes \### 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*
- Loading branch information
Luke Pafford
committed
Aug 22, 2024
1 parent
af50620
commit e97fed7
Showing
9 changed files
with
1,360 additions
and
64 deletions.
There are no files selected for viewing
415 changes: 415 additions & 0 deletions
415
...ws-cdk/custom-resource-handlers/lib/aws-route53/cross-account-record-set-handler/index.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/@aws-cdk/custom-resource-handlers/lib/aws-route53/sts-util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Return the region that hosts the Route53 endpoint | ||
* | ||
* Route53 is a partitional service: the control plane lives in one particular region, | ||
* which is different for every partition. | ||
* | ||
* The SDK knows how to convert a "target region" to a "route53 endpoint", which | ||
* equates to a (potentially different) region. However, when we use STS | ||
* AssumeRole credentials, we must grab credentials that will work in that | ||
* region. | ||
* | ||
* By default, STS AssumeRole will call the STS endpoint for the same region | ||
* as the Lambda runs in. Normally, this is all good. However, when the AssumeRole | ||
* is used to assume a role in a different account A, the AssumeRole will fail if the | ||
* Lambda is executing in an an opt-in region R to which account A has not been opted in. | ||
* | ||
* To solve this, we will always AssumeRole in the same region as the Route53 call will | ||
* resolve to. | ||
*/ | ||
export function route53Region(region: string) { | ||
const partitions = { | ||
'cn': 'cn-northwest-1', | ||
'us-gov': 'us-gov-west-1', | ||
'us-iso': 'us-iso-east-1', | ||
'us-isob': 'us-isob-east-1', | ||
'eu-isoe': 'eu-isoe-west-1', | ||
'us-isof': 'us-isof-south-1', | ||
}; | ||
|
||
for (const [prefix, mainRegion] of Object.entries(partitions)) { | ||
if (region.startsWith(`${prefix}-`)) { | ||
return mainRegion; | ||
} | ||
} | ||
|
||
// Default for commercial partition | ||
return 'us-east-1'; | ||
} |
Oops, something went wrong.