route53: support IP-based routing
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
I want to enable the configuration of [IP-based routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-ipbased.html) in Route 53 through the L2 construct.
### Use Case
Currently, to configure IP-based routing in Route 53, it is necessary to use L1 constructs.
```ts
const locationName = 'myLocation'
// Create a CIDR collection
const cidrCollection = new route53.CfnCidrCollection(this, 'MyCidrCollection', {
name: 'MyCidrCollection',
locations: [
{
cidrList: ['192.168.1.0/24', '192.168.2.0/24'],
locationName,
}
]
});
// Create a RecordSet that uses the CIDR collection
new route53.CfnRecordSet(this, 'MyRecordSet', {
// ... other properties ...
// Reference the CIDR collection
cidrRoutingConfig: {
collectionId: cidrCollection.ref,
locationName,
},
});
```
### Proposed Solution
I believe that generating CfnCidrCollection within the recordSet constructor allows for intuitive configuration.
However, additional handling is required when [sharing the same collection across different RecordSets. ](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-ipbased.html)
`IP-based routing resource record sets reference a location in a collection, and all resource record sets for the same record set name and type must reference the same collection. For example, if you create websites in two Regions and want to direct DNS queries from two different CIDR locations to a specific website based on the originating IP addresses, then both of those locations must be listed in the same CIDR collection.`
```ts
interface CidrRoutingConfig {
collectionName?: string;
locations: Location[];
// Define only if sharing the same collection with other RecordSets
collection?: CfnCidrCollection:
}
interface Location {
cidrList: string[];
locationName?: string;
}
const record1 = new route53.RecordSet(this, 'IPBasedRoutingRecordSet1', {
// ... other properties ...
cidrRoutingConfig: {
collectionName: 'MyCollection', // optional
locations: [
{
locationName: 'Location1', // optional
cidrList: ['192.168.1.0/24', '192.168.2.0/24'],
},
],
},
});
// By adding Location2 to the CfnCidrCollection created in record1, the same CidrCollection can be shared.
const record2 = new route53.RecordSet(this, 'IPBasedRoutingRecordSet2', {
// ... other properties ...
cidrRoutingConfig: {
collection: record1.cidrCollection,
locations: [
{
locationName: 'Location2', // optional
cidrList: ['192.168.3.0/24', '192.168.4.0/24'],
},
],
},
});
```
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.116.0
### Environment details (OS name and version, etc.)
irrelevant
Contributor guide
Research direction
Start with the Route53 L2 RecordSet and CfnCidrCollection constructs and the AWS IP-based routing documentation linked in the issue. Clarify how a collection is created, extended, and shared across record sets, then validate the API against the two-record example and existing construct behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100