feat(route53): ip-based routing
In this PR, I have implemented support for IP-based routing.
We can configure it from the cidrRoutingConfig as shown in the following example:
declare const myZone: route53.HostedZone;
const record1 = new route53.ARecord(this, 'ARecordIpBased1', {
zone: myZone,
recordName: 'test',
target: route53.RecordTarget.fromIpAddresses('1.2.3.4'),
cidrRoutingConfig: {
cidrList: ['192.168.1.0/24', '192.168.16.0/20'],
locationName: 'TokyoServer',
collectionName: 'myCollection',
},
});
// You can also add a new Location to an existing CidrCollection
// Ensure all locations for the same record set name and type are part of the same CIDR collection to guarantee consistent routing.
const record2 = new route53.ARecord(this, 'ARecordIpBased2', {
zone: myZone,
recordName: 'test',
target: route53.RecordTarget.fromIpAddresses('2.3.4.5'),
cidrRoutingConfig: {
cidrList: ['192.168.2.0/24', '192.168.48.0/20'],
locationName: 'LondonServer',
collection: record1.cidrCollection,
},
});
// To define a zero bit CIDR block (0.0.0.0/0 or ::/0), use the default ("*") location.
const record3 = new route53.ARecord(this, 'ARecordIpBased3', {
zone: myZone,
recordName: 'default',
target: route53.RecordTarget.fromIpAddresses('1.2.3.4'),
cidrRoutingConfig: {
locationName: '*',
},
});
Question
As mentioned above, the existing cidrCollection can be passed as collection argument.
During this process, a new Location is added to the existing Locations in the cidrCollection.
This code works, but I am not confident about the implementation approach. I would greatly appreciate any candid feedback.
if (cidrRoutingConfig.collection) {
this._cidrCollection = cidrRoutingConfig.collection;
const currentLocations = this._cidrCollection.locations ?? [];
const locationsAsArray = Array.isArray(currentLocations) ? currentLocations : [currentLocations];
this._cidrCollection.addPropertyOverride('Locations', [...locationsAsArray.map((location) => {
// Since the location is either CfnCidrCollection.LocationProperty or IResolvable,
// use a type guard function to ascertain its exact type.
if ('cidrList' in location && 'locationName' in location) {
return {
CidrList: location.cidrList,
LocationName: location.locationName,
};
}
return location;
}), {
CidrList: cidrList,
LocationName: locationName,
}]);
}
Closes #28801.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.
oh.. I've forgotten this.
AWS CodeBuild CI Report
- CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
- Commit ID: b6df5b230979260fec7351311d0bcfec3901a4a9
- Result: FAILED
- Build Logs (available for 30 days)
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository
This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.