From 7651ea7e1f0df793571a6ab9e0088cf21267895e Mon Sep 17 00:00:00 2001 From: tttol Date: Mon, 28 Apr 2025 17:19:02 +0900 Subject: [PATCH 01/20] add prop --- .../aws-route53/lib/cidr-routing-config.ts | 29 +++++++++++++++++++ .../aws-cdk-lib/aws-route53/lib/record-set.ts | 12 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts new file mode 100644 index 0000000000000..82c6a686d7a77 --- /dev/null +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -0,0 +1,29 @@ +import { UnscopedValidationError } from "../../core"; + +export class CidrRoutingConfig { + /** + * The CIDR collection ID. + */ + readonly collectionId: string; + + /** + * The CIDR collection location name. + */ + readonly locationName: string; + + constructor(collectionId: string, locationName: string) { + const COLLECTION_ID_REGEX = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/; + const LOCATION_NAME_REGEX = /^[0-9A-Za-z_\-\*]{1,16}$/; + + if (!COLLECTION_ID_REGEX.test(collectionId?.trim() ?? '')) { + throw new UnscopedValidationError('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + } + if (!LOCATION_NAME_REGEX.test(locationName?.trim() ?? '')) { + throw new UnscopedValidationError('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); + } + this.collectionId = collectionId; + this.locationName = locationName; + } +} + + diff --git a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts index 952059993412d..4b4289e67e4b3 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts @@ -11,6 +11,7 @@ import { ValidationError } from '../../core/lib/errors'; import { addConstructMetadata } from '../../core/lib/metadata-resource'; import { CrossAccountZoneDelegationProvider } from '../../custom-resource-handlers/dist/aws-route53/cross-account-zone-delegation-provider.generated'; import { DeleteExistingRecordSetProvider } from '../../custom-resource-handlers/dist/aws-route53/delete-existing-record-set-provider.generated'; +import { CidrRoutingConfig } from './cidr-routing-config'; const CROSS_ACCOUNT_ZONE_DELEGATION_RESOURCE_TYPE = 'Custom::CrossAccountZoneDelegation'; const DELETE_EXISTING_RECORD_SET_RESOURCE_TYPE = 'Custom::DeleteExistingRecordSet'; @@ -276,6 +277,16 @@ export interface RecordSetOptions { * @default - No health check configured */ readonly healthCheck?: IHealthCheck; + + /** + * The object that is specified in resource record set object when you are linking a resource record set to a CIDR location. + * + * A LocationName with an asterisk “*” can be used to create a default CIDR record. CollectionId is still required for default record. + * + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-recordset.html#cfn-route53-recordset-cidrroutingconfig + * @default - No CIDR routing configured + */ + readonly cidrRoutingConfig?: CidrRoutingConfig; } /** @@ -393,6 +404,7 @@ export class RecordSet extends Resource implements IRecordSet { weight: props.weight, region: props.region, healthCheckId: props.healthCheck?.healthCheckId, + cidrRoutingConfig: props.cidrRoutingConfig, }); this.domainName = recordSet.ref; From 681a4e7ad49319782abad3341d0e2510e1661879 Mon Sep 17 00:00:00 2001 From: tttol Date: Mon, 28 Apr 2025 21:31:36 +0900 Subject: [PATCH 02/20] add UT --- .../aws-route53/lib/cidr-routing-config.ts | 5 ++ .../test/cidr-routing-config.test.ts | 64 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index 82c6a686d7a77..5184f8898b67d 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -1,5 +1,10 @@ import { UnscopedValidationError } from "../../core"; +/** + * Configuration for CIDR routing in Route 53 resource record set objects. + * + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-recordset.html#cfn-route53-recordset-cidrroutingconfig + */ export class CidrRoutingConfig { /** * The CIDR collection ID. diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts new file mode 100644 index 0000000000000..ba0b5baf41833 --- /dev/null +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -0,0 +1,64 @@ +import { CidrRoutingConfig } from '../lib/cidr-routing-config'; + +describe('CidrRoutingConfig', () => { + test('creates successfully with valid parameters', () => { + const config = new CidrRoutingConfig( + '12345678-1234-1234-1234-123456789012', + 'valid-location' + ); + expect(config.collectionId).toBe('12345678-1234-1234-1234-123456789012'); + expect(config.locationName).toBe('valid-location'); + }); + + test('throws error with invalid collectionId format', () => { + expect(() => { + new CidrRoutingConfig('invalid-uuid', 'valid-location'); + }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + }); + + test('throws error with invalid locationName format', () => { + expect(() => { + new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', 'invalid@location'); + }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); + }); + + test('throws error with empty collectionId', () => { + expect(() => { + new CidrRoutingConfig('', 'valid-location'); + }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + }); + + test('throws error with empty locationName', () => { + expect(() => { + new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', ''); + }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); + }); + + test('throws error with null collectionId', () => { + expect(() => { + new CidrRoutingConfig(null as any, 'valid-location'); + }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + }); + + test('throws error with null locationName', () => { + expect(() => { + new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', null as any); + }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); + }); + + test('accepts valid locationName with asterisk', () => { + const config = new CidrRoutingConfig( + '12345678-1234-1234-1234-123456789012', + 'valid*location' + ); + expect(config.locationName).toBe('valid*location'); + }); + + test('accepts valid locationName with underscore', () => { + const config = new CidrRoutingConfig( + '12345678-1234-1234-1234-123456789012', + 'valid_location' + ); + expect(config.locationName).toBe('valid_location'); + }); +}); From 205317e67df7375100800f0824d515eb1547bb86 Mon Sep 17 00:00:00 2001 From: tttol Date: Mon, 28 Apr 2025 22:10:02 +0900 Subject: [PATCH 03/20] fix ut --- .../test/cidr-routing-config.test.ts | 111 ++++++++++-------- 1 file changed, 63 insertions(+), 48 deletions(-) diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index ba0b5baf41833..9180df17e8c01 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -10,55 +10,70 @@ describe('CidrRoutingConfig', () => { expect(config.locationName).toBe('valid-location'); }); - test('throws error with invalid collectionId format', () => { - expect(() => { - new CidrRoutingConfig('invalid-uuid', 'valid-location'); - }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + describe('accepts valid locationName with asterisk/underscore', () => { + test.each([ + { + name: 'asterisk', + locationName: 'valid*location', + expected: 'valid*location' + }, + { + name: 'underscore', + locationName: 'valid_location', + expected: 'valid_location' + } + ])('$name', ({ locationName, expected }) => { + const config = new CidrRoutingConfig( + '12345678-1234-1234-1234-123456789012', + locationName + ); + expect(config.collectionId).toBe('12345678-1234-1234-1234-123456789012'); + expect(config.locationName).toBe(expected); + }); }); - test('throws error with invalid locationName format', () => { - expect(() => { - new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', 'invalid@location'); - }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); - }); - - test('throws error with empty collectionId', () => { - expect(() => { - new CidrRoutingConfig('', 'valid-location'); - }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); - }); - - test('throws error with empty locationName', () => { - expect(() => { - new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', ''); - }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); - }); - - test('throws error with null collectionId', () => { - expect(() => { - new CidrRoutingConfig(null as any, 'valid-location'); - }).toThrow('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); - }); - - test('throws error with null locationName', () => { - expect(() => { - new CidrRoutingConfig('12345678-1234-1234-1234-123456789012', null as any); - }).toThrow('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); - }); - - test('accepts valid locationName with asterisk', () => { - const config = new CidrRoutingConfig( - '12345678-1234-1234-1234-123456789012', - 'valid*location' - ); - expect(config.locationName).toBe('valid*location'); - }); - - test('accepts valid locationName with underscore', () => { - const config = new CidrRoutingConfig( - '12345678-1234-1234-1234-123456789012', - 'valid_location' - ); - expect(config.locationName).toBe('valid_location'); + describe('throws error with invalid parameters', () => { + test.each([ + { + name: 'invalid collectionId format', + collectionId: 'invalid-uuid', + locationName: 'valid-location', + expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + }, + { + name: 'invalid locationName format', + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: 'invalid@location', + expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' + }, + { + name: 'empty collectionId', + collectionId: '', + locationName: 'valid-location', + expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + }, + { + name: 'empty locationName', + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: '', + expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' + }, + { + name: 'null collectionId', + collectionId: null as any, + locationName: 'valid-location', + expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + }, + { + name: 'null locationName', + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: null as any, + expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' + } + ])('$name', ({ collectionId, locationName, expectedError }) => { + expect(() => { + new CidrRoutingConfig(collectionId, locationName); + }).toThrow(expectedError); + }); }); }); From 13edc49a10f235de0a27a5d759cd71fda7a5bd1a Mon Sep 17 00:00:00 2001 From: tttol Date: Tue, 29 Apr 2025 07:01:18 +0900 Subject: [PATCH 04/20] add integ test --- .../test/integ.cidr-routing-config.ts | 32 +++++++++++++++++++ .../aws-cdk-lib/aws-route53/lib/record-set.ts | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts new file mode 100644 index 0000000000000..bcea688922ed3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -0,0 +1,32 @@ +import { App, Stack, StackProps } from "aws-cdk-lib"; +import { Construct } from 'constructs'; +import * as route53 from "aws-cdk-lib/aws-route53"; +import { IntegTest } from "@aws-cdk/integ-tests-alpha"; + +class TestStack extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + const zone = new route53.PublicHostedZone(this, 'HostedZone', { + zoneName: 'cdk.test' + }); + + new route53.ARecord(this, 'CidrRoutingConfig', { + zone: zone, + target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), + setIdentifier: 'test', + cidrRoutingConfig: { + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: 'valid_location' + }, + }) + } +} + +const app = new App(); +const stack = new TestStack(app, 'CidrRoutingConfig'); + +new IntegTest(app, 'CidrRoutingConfigInteg', { + testCases: [stack], +}); +app.synth(); \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts index 4b4289e67e4b3..68ead84c2b598 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts @@ -360,7 +360,7 @@ export class RecordSet extends Resource implements IRecordSet { if (props.setIdentifier && (props.setIdentifier.length < 1 || props.setIdentifier.length > 128)) { throw new ValidationError(`setIdentifier must be between 1 and 128 characters long, got: ${props.setIdentifier.length}`, this); } - if (props.setIdentifier && props.weight === undefined && !props.geoLocation && !props.region && !props.multiValueAnswer) { + if (props.setIdentifier && props.weight === undefined && !props.geoLocation && !props.region && !props.multiValueAnswer && !props.cidrRoutingConfig) { throw new ValidationError('setIdentifier can only be specified for non-simple routing policies', this); } if (props.multiValueAnswer && props.target.aliasTarget) { @@ -372,6 +372,7 @@ export class RecordSet extends Resource implements IRecordSet { props.region, props.weight, props.multiValueAnswer, + props.cidrRoutingConfig, ].filter((variable) => variable !== undefined).length; if (nonSimpleRoutingPolicies > 1) { throw new ValidationError('Only one of region, weight, multiValueAnswer or geoLocation can be defined', this); From ccadb762bee8608008552f67b9fddb539dfdaafc Mon Sep 17 00:00:00 2001 From: tttol Date: Wed, 30 Apr 2025 05:38:59 +0900 Subject: [PATCH 05/20] add integ test --- .../CidrRoutingConfig.assets.json | 20 +++ .../CidrRoutingConfig.template.json | 82 +++++++++ ...efaultTestDeployAssert2D4BBAED.assets.json | 20 +++ ...aultTestDeployAssert2D4BBAED.template.json | 36 ++++ .../cdk.out | 1 + .../integ.json | 12 ++ .../manifest.json | 158 ++++++++++++++++++ .../tree.json | 1 + .../test/integ.cidr-routing-config.ts | 12 +- 9 files changed, 340 insertions(+), 2 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json new file mode 100644 index 0000000000000..46c319d766317 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json @@ -0,0 +1,20 @@ +{ + "version": "41.0.0", + "files": { + "55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54": { + "displayName": "CidrRoutingConfig Template", + "source": { + "path": "CidrRoutingConfig.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json new file mode 100644 index 0000000000000..0ef3bf37322cf --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json @@ -0,0 +1,82 @@ +{ + "Resources": { + "HostedZoneDB99F866": { + "Type": "AWS::Route53::HostedZone", + "Properties": { + "Name": "cdk.test." + } + }, + "CidrCollection": { + "Type": "AWS::Route53::CidrCollection", + "Properties": { + "Locations": [ + { + "CidrList": [ + "192.168.1.0/24" + ], + "LocationName": "test_location" + } + ], + "Name": "test-collection" + } + }, + "CidrRoutingConfig2AF5DEDB": { + "Type": "AWS::Route53::RecordSet", + "Properties": { + "CidrRoutingConfig": { + "CollectionId": { + "Fn::GetAtt": [ + "CidrCollection", + "Id" + ] + }, + "LocationName": "test_location" + }, + "HostedZoneId": { + "Ref": "HostedZoneDB99F866" + }, + "Name": "cdk.test.", + "ResourceRecords": [ + "1.2.3.4" + ], + "SetIdentifier": "test", + "TTL": "1800", + "Type": "A" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets.json new file mode 100644 index 0000000000000..446ed8a874050 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets.json @@ -0,0 +1,20 @@ +{ + "version": "41.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "displayName": "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED Template", + "source": { + "path": "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/cdk.out new file mode 100644 index 0000000000000..188478b55560e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"41.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/integ.json new file mode 100644 index 0000000000000..8959a8aa8bdf4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "41.0.0", + "testCases": { + "CidrRoutingConfigInteg/DefaultTest": { + "stacks": [ + "CidrRoutingConfig" + ], + "assertionStack": "CidrRoutingConfigInteg/DefaultTest/DeployAssert", + "assertionStackName": "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json new file mode 100644 index 0000000000000..c18314a89ef5d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json @@ -0,0 +1,158 @@ +{ + "version": "42.0.0", + "artifacts": { + "CidrRoutingConfig.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CidrRoutingConfig.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CidrRoutingConfig": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "CidrRoutingConfig.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "CidrRoutingConfig.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "CidrRoutingConfig.assets" + ], + "metadata": { + "/CidrRoutingConfig/HostedZone": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "zoneName": "*" + } + }, + { + "type": "aws:cdk:analytics:construct", + "data": { + "zoneName": "*" + } + } + ], + "/CidrRoutingConfig/HostedZone/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HostedZoneDB99F866" + } + ], + "/CidrRoutingConfig/CidrCollection": [ + { + "type": "aws:cdk:logicalId", + "data": "CidrCollection" + } + ], + "/CidrRoutingConfig/CidrRoutingConfig": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } + }, + { + "type": "aws:cdk:analytics:construct", + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } + } + ], + "/CidrRoutingConfig/CidrRoutingConfig/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "CidrRoutingConfig2AF5DEDB" + } + ], + "/CidrRoutingConfig/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CidrRoutingConfig/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CidrRoutingConfig" + }, + "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "CidrRoutingConfigIntegDefaultTestDeployAssert2D4BBAED.assets" + ], + "metadata": { + "/CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CidrRoutingConfigInteg/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + }, + "minimumCliVersion": "2.1006.0" +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json new file mode 100644 index 0000000000000..f0931f482810d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json @@ -0,0 +1 @@ +{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig","children":{"HostedZone":{"id":"HostedZone","path":"CidrRoutingConfig/HostedZone","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test."}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnHostedZone","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.PublicHostedZone","version":"0.0.0","metadata":[{"zoneName":"*"},{"zoneName":"*"}]}},"CidrCollection":{"id":"CidrCollection","path":"CidrRoutingConfig/CidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"test_location"}],"name":"test-collection"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnCidrCollection","version":"0.0.0"}},"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig/CidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/CidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["CidrCollection","Id"]},"locationName":"test_location"},"hostedZoneId":{"Ref":"HostedZoneDB99F866"},"name":"cdk.test.","resourceRecords":["1.2.3.4"],"setIdentifier":"test","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnRecordSet","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.ARecord","version":"0.0.0","metadata":[{"zone":"*","target":"*","setIdentifier":"*"},{"zone":"*","target":"*","setIdentifier":"*"}]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfig/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfig/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}},"CidrRoutingConfigInteg":{"id":"CidrRoutingConfigInteg","path":"CidrRoutingConfigInteg","children":{"DefaultTest":{"id":"DefaultTest","path":"CidrRoutingConfigInteg/DefaultTest","children":{"Default":{"id":"Default","path":"CidrRoutingConfigInteg/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"}}} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index bcea688922ed3..8eb7662e634a7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -11,13 +11,21 @@ class TestStack extends Stack { zoneName: 'cdk.test' }); + const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { + name: 'test-collection', + locations: [{ + cidrList: ['192.168.1.0/24'], + locationName: 'test_location', + }] + }); + new route53.ARecord(this, 'CidrRoutingConfig', { zone: zone, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', cidrRoutingConfig: { - collectionId: '12345678-1234-1234-1234-123456789012', - locationName: 'valid_location' + collectionId: cidrCollection.attrId, + locationName: 'test_location' }, }) } From cb226538564c7948a070290d1d5ad5ca2d4fb984 Mon Sep 17 00:00:00 2001 From: tttol Date: Wed, 30 Apr 2025 06:10:08 +0900 Subject: [PATCH 06/20] update README --- packages/aws-cdk-lib/aws-route53/README.md | 25 ++++++++++++++++++- .../aws-cdk-lib/aws-route53/lib/record-set.ts | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index 7b376d27a945a..451eefc4a0350 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -204,7 +204,30 @@ new route53.ARecord(this, 'ARecordMultiValue1', { }); ``` -To specify a unique identifier to differentiate among multiple resource record sets that have the same combination of name and type, use the `setIdentifier` parameter: +To enable [IP-based routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-ipbased.html), use the `cidrRoutingConfig` parameter: + +```ts +declare const myZone: route53.HostedZone; + +const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { + name: 'test-collection', + locations: [{ + cidrList: ['192.168.1.0/24'], + locationName: 'my_location', + }] +}); + +new route53.ARecord(this, 'ARecordCIDR', { + zone: myZone, + target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), + cidrRoutingConfig: { + collectionId: cidrCollection.attrId, + locationName: 'my_location', + }, +}); +``` + +To specify a unique identifier to differentiate among multiple resource record sets that have the same combination of name and type, use the `setIdentifier` parameter: ```ts declare const myZone: route53.HostedZone; diff --git a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts index 68ead84c2b598..adcecf81bd822 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts @@ -375,7 +375,7 @@ export class RecordSet extends Resource implements IRecordSet { props.cidrRoutingConfig, ].filter((variable) => variable !== undefined).length; if (nonSimpleRoutingPolicies > 1) { - throw new ValidationError('Only one of region, weight, multiValueAnswer or geoLocation can be defined', this); + throw new ValidationError('Only one of region, weight, multiValueAnswer, geoLocation or cidrRoutingConfig can be defined', this); } this.geoLocation = props.geoLocation; From 7606499d825a45b78d605b60bf5dc1da4bedec0c Mon Sep 17 00:00:00 2001 From: tttol Date: Thu, 1 May 2025 06:49:31 +0900 Subject: [PATCH 07/20] fix error --- .../manifest.json | 20 ++------- .../tree.json | 2 +- .../test/integ.cidr-routing-config.ts | 6 +-- .../aws-route53/lib/cidr-routing-config.ts | 43 +++++++++++++------ packages/aws-cdk-lib/aws-route53/lib/index.ts | 1 + .../aws-cdk-lib/aws-route53/lib/record-set.ts | 7 +-- .../test/cidr-routing-config.test.ts | 41 ++++++++++-------- 7 files changed, 66 insertions(+), 54 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json index c18314a89ef5d..39241c5672b50 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json @@ -37,15 +37,11 @@ "/CidrRoutingConfig/HostedZone": [ { "type": "aws:cdk:analytics:construct", - "data": { - "zoneName": "*" - } + "data": "*" }, { "type": "aws:cdk:analytics:construct", - "data": { - "zoneName": "*" - } + "data": "*" } ], "/CidrRoutingConfig/HostedZone/Resource": [ @@ -63,19 +59,11 @@ "/CidrRoutingConfig/CidrRoutingConfig": [ { "type": "aws:cdk:analytics:construct", - "data": { - "zone": "*", - "target": "*", - "setIdentifier": "*" - } + "data": "*" }, { "type": "aws:cdk:analytics:construct", - "data": { - "zone": "*", - "target": "*", - "setIdentifier": "*" - } + "data": "*" } ], "/CidrRoutingConfig/CidrRoutingConfig/Resource": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json index f0931f482810d..2b7761b7f6269 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json @@ -1 +1 @@ -{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig","children":{"HostedZone":{"id":"HostedZone","path":"CidrRoutingConfig/HostedZone","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test."}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnHostedZone","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.PublicHostedZone","version":"0.0.0","metadata":[{"zoneName":"*"},{"zoneName":"*"}]}},"CidrCollection":{"id":"CidrCollection","path":"CidrRoutingConfig/CidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"test_location"}],"name":"test-collection"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnCidrCollection","version":"0.0.0"}},"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig/CidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/CidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["CidrCollection","Id"]},"locationName":"test_location"},"hostedZoneId":{"Ref":"HostedZoneDB99F866"},"name":"cdk.test.","resourceRecords":["1.2.3.4"],"setIdentifier":"test","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnRecordSet","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.ARecord","version":"0.0.0","metadata":[{"zone":"*","target":"*","setIdentifier":"*"},{"zone":"*","target":"*","setIdentifier":"*"}]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfig/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfig/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}},"CidrRoutingConfigInteg":{"id":"CidrRoutingConfigInteg","path":"CidrRoutingConfigInteg","children":{"DefaultTest":{"id":"DefaultTest","path":"CidrRoutingConfigInteg/DefaultTest","children":{"Default":{"id":"Default","path":"CidrRoutingConfigInteg/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"}}} \ No newline at end of file +{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig","children":{"HostedZone":{"id":"HostedZone","path":"CidrRoutingConfig/HostedZone","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test."}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2","metadata":["*","*"]}},"CidrCollection":{"id":"CidrCollection","path":"CidrRoutingConfig/CidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"test_location"}],"name":"test-collection"}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig/CidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/CidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["CidrCollection","Id"]},"locationName":"test_location"},"hostedZoneId":{"Ref":"HostedZoneDB99F866"},"name":"cdk.test.","resourceRecords":["1.2.3.4"],"setIdentifier":"test","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2","metadata":["*","*"]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfig/BootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfig/CheckBootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CidrRoutingConfigInteg":{"id":"CidrRoutingConfigInteg","path":"CidrRoutingConfigInteg","children":{"DefaultTest":{"id":"DefaultTest","path":"CidrRoutingConfigInteg/DefaultTest","children":{"Default":{"id":"Default","path":"CidrRoutingConfigInteg/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index 8eb7662e634a7..550299eee2251 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -23,11 +23,11 @@ class TestStack extends Stack { zone: zone, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', - cidrRoutingConfig: { + cidrRoutingConfig: route53.CidrRoutingConfig.new({ collectionId: cidrCollection.attrId, locationName: 'test_location' - }, - }) + }), + }); } } diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index 5184f8898b67d..c4cd6a89d74e3 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -1,11 +1,33 @@ -import { UnscopedValidationError } from "../../core"; +import { Token, UnscopedValidationError } from '../../core'; + +/** + * Properties for configuring CIDR routing in Route 53 resource record set objects. + */ +export interface CidrRoutingConfigProps { + /** + * The CIDR collection ID. + */ + readonly collectionId: string; + + /** + * The CIDR collection location name. + */ + readonly locationName: string; +} /** * Configuration for CIDR routing in Route 53 resource record set objects. - * + * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-recordset.html#cfn-route53-recordset-cidrroutingconfig */ export class CidrRoutingConfig { + /** + * Creates a new instance of CidrRoutingConfig + */ + public static new(props: CidrRoutingConfigProps): CidrRoutingConfig { + return new CidrRoutingConfig(props); + } + /** * The CIDR collection ID. */ @@ -16,19 +38,16 @@ export class CidrRoutingConfig { */ readonly locationName: string; - constructor(collectionId: string, locationName: string) { + private constructor(props: CidrRoutingConfigProps) { const COLLECTION_ID_REGEX = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/; const LOCATION_NAME_REGEX = /^[0-9A-Za-z_\-\*]{1,16}$/; - - if (!COLLECTION_ID_REGEX.test(collectionId?.trim() ?? '')) { - throw new UnscopedValidationError('collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)'); + if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) { + throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`); } - if (!LOCATION_NAME_REGEX.test(locationName?.trim() ?? '')) { - throw new UnscopedValidationError('locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks'); + if (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) { + throw new UnscopedValidationError(`locationName(${props.locationName}) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks`); } - this.collectionId = collectionId; - this.locationName = locationName; + this.collectionId = props.collectionId; + this.locationName = props.locationName; } } - - diff --git a/packages/aws-cdk-lib/aws-route53/lib/index.ts b/packages/aws-cdk-lib/aws-route53/lib/index.ts index 7997e835e6eba..dd94003c959a6 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/index.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/index.ts @@ -5,6 +5,7 @@ export * from './hosted-zone-ref'; export * from './key-signing-key'; export * from './record-set'; export * from './vpc-endpoint-service-domain-name'; +export * from './cidr-routing-config'; export * from './geo-location'; export * from './health-check'; diff --git a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts index adcecf81bd822..babdbc03348fd 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/record-set.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/record-set.ts @@ -1,5 +1,6 @@ import { Construct } from 'constructs'; import { AliasRecordTargetConfig, IAliasRecordTarget } from './alias-record-target'; +import { CidrRoutingConfig } from './cidr-routing-config'; import { GeoLocation } from './geo-location'; import { IHealthCheck } from './health-check'; import { IHostedZone } from './hosted-zone-ref'; @@ -11,7 +12,6 @@ import { ValidationError } from '../../core/lib/errors'; import { addConstructMetadata } from '../../core/lib/metadata-resource'; import { CrossAccountZoneDelegationProvider } from '../../custom-resource-handlers/dist/aws-route53/cross-account-zone-delegation-provider.generated'; import { DeleteExistingRecordSetProvider } from '../../custom-resource-handlers/dist/aws-route53/delete-existing-record-set-provider.generated'; -import { CidrRoutingConfig } from './cidr-routing-config'; const CROSS_ACCOUNT_ZONE_DELEGATION_RESOURCE_TYPE = 'Custom::CrossAccountZoneDelegation'; const DELETE_EXISTING_RECORD_SET_RESOURCE_TYPE = 'Custom::DeleteExistingRecordSet'; @@ -280,7 +280,7 @@ export interface RecordSetOptions { /** * The object that is specified in resource record set object when you are linking a resource record set to a CIDR location. - * + * * A LocationName with an asterisk “*” can be used to create a default CIDR record. CollectionId is still required for default record. * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-recordset.html#cfn-route53-recordset-cidrroutingconfig @@ -360,7 +360,8 @@ export class RecordSet extends Resource implements IRecordSet { if (props.setIdentifier && (props.setIdentifier.length < 1 || props.setIdentifier.length > 128)) { throw new ValidationError(`setIdentifier must be between 1 and 128 characters long, got: ${props.setIdentifier.length}`, this); } - if (props.setIdentifier && props.weight === undefined && !props.geoLocation && !props.region && !props.multiValueAnswer && !props.cidrRoutingConfig) { + if (props.setIdentifier && props.weight === undefined && !props.geoLocation && !props.region && !props.multiValueAnswer + && !props.cidrRoutingConfig) { throw new ValidationError('setIdentifier can only be specified for non-simple routing policies', this); } if (props.multiValueAnswer && props.target.aliasTarget) { diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index 9180df17e8c01..f264cec6dce36 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -2,10 +2,10 @@ import { CidrRoutingConfig } from '../lib/cidr-routing-config'; describe('CidrRoutingConfig', () => { test('creates successfully with valid parameters', () => { - const config = new CidrRoutingConfig( - '12345678-1234-1234-1234-123456789012', - 'valid-location' - ); + const config = CidrRoutingConfig.new({ + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: 'valid-location', + }); expect(config.collectionId).toBe('12345678-1234-1234-1234-123456789012'); expect(config.locationName).toBe('valid-location'); }); @@ -15,18 +15,18 @@ describe('CidrRoutingConfig', () => { { name: 'asterisk', locationName: 'valid*location', - expected: 'valid*location' + expected: 'valid*location', }, { name: 'underscore', locationName: 'valid_location', - expected: 'valid_location' - } + expected: 'valid_location', + }, ])('$name', ({ locationName, expected }) => { - const config = new CidrRoutingConfig( - '12345678-1234-1234-1234-123456789012', - locationName - ); + const config = CidrRoutingConfig.new({ + collectionId: '12345678-1234-1234-1234-123456789012', + locationName, + }); expect(config.collectionId).toBe('12345678-1234-1234-1234-123456789012'); expect(config.locationName).toBe(expected); }); @@ -38,41 +38,44 @@ describe('CidrRoutingConfig', () => { name: 'invalid collectionId format', collectionId: 'invalid-uuid', locationName: 'valid-location', - expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + expectedError: 'collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', }, { name: 'invalid locationName format', collectionId: '12345678-1234-1234-1234-123456789012', locationName: 'invalid@location', - expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' + expectedError: 'locationName(invalid@location) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks', }, { name: 'empty collectionId', collectionId: '', locationName: 'valid-location', - expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + expectedError: 'collectionId() is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', }, { name: 'empty locationName', collectionId: '12345678-1234-1234-1234-123456789012', locationName: '', - expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' + expectedError: 'locationName() is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks', }, { name: 'null collectionId', collectionId: null as any, locationName: 'valid-location', - expectedError: 'collectionId is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits)' + expectedError: 'collectionId(null) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', }, { name: 'null locationName', collectionId: '12345678-1234-1234-1234-123456789012', locationName: null as any, - expectedError: 'locationName is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks' - } + expectedError: 'locationName(null) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks', + }, ])('$name', ({ collectionId, locationName, expectedError }) => { expect(() => { - new CidrRoutingConfig(collectionId, locationName); + CidrRoutingConfig.new({ + collectionId, + locationName, + }); }).toThrow(expectedError); }); }); From e956917a79a2ffd5feb0da94e2deb9d5d29eec03 Mon Sep 17 00:00:00 2001 From: tttol Date: Thu, 1 May 2025 06:53:33 +0900 Subject: [PATCH 08/20] update README --- packages/aws-cdk-lib/aws-route53/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index 451eefc4a0350..60ff139bef54c 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -217,13 +217,14 @@ const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { }] }); -new route53.ARecord(this, 'ARecordCIDR', { - zone: myZone, +new route53.ARecord(this, 'CidrRoutingConfig', { + zone: zone, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), - cidrRoutingConfig: { + setIdentifier: 'test', + cidrRoutingConfig: route53.CidrRoutingConfig.new({ collectionId: cidrCollection.attrId, - locationName: 'my_location', - }, + locationName: 'test_location' + }), }); ``` From 49a37eabcfa434e410f1cc5ef5816fed7591502a Mon Sep 17 00:00:00 2001 From: tttol Date: Thu, 1 May 2025 19:40:35 +0900 Subject: [PATCH 09/20] fix lint error --- .../test/integ.cidr-routing-config.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index 550299eee2251..0207ebba66ebf 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -1,14 +1,14 @@ -import { App, Stack, StackProps } from "aws-cdk-lib"; +import { App, Stack, StackProps } from 'aws-cdk-lib'; import { Construct } from 'constructs'; -import * as route53 from "aws-cdk-lib/aws-route53"; -import { IntegTest } from "@aws-cdk/integ-tests-alpha"; +import * as route53 from 'aws-cdk-lib/aws-route53'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; class TestStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); const zone = new route53.PublicHostedZone(this, 'HostedZone', { - zoneName: 'cdk.test' + zoneName: 'cdk.test', }); const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { @@ -16,7 +16,7 @@ class TestStack extends Stack { locations: [{ cidrList: ['192.168.1.0/24'], locationName: 'test_location', - }] + },] }); new route53.ARecord(this, 'CidrRoutingConfig', { @@ -25,10 +25,10 @@ class TestStack extends Stack { setIdentifier: 'test', cidrRoutingConfig: route53.CidrRoutingConfig.new({ collectionId: cidrCollection.attrId, - locationName: 'test_location' + locationName: 'test_location', }), }); - } + } } const app = new App(); @@ -37,4 +37,4 @@ const stack = new TestStack(app, 'CidrRoutingConfig'); new IntegTest(app, 'CidrRoutingConfigInteg', { testCases: [stack], }); -app.synth(); \ No newline at end of file +app.synth(); From 39df4fe4863521fd2144f2f6b621833ad482dbbe Mon Sep 17 00:00:00 2001 From: tttol Date: Fri, 2 May 2025 06:16:12 +0900 Subject: [PATCH 10/20] fix typo --- .../test/aws-route53/test/integ.cidr-routing-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index 0207ebba66ebf..2a649c15d0d0a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -16,7 +16,7 @@ class TestStack extends Stack { locations: [{ cidrList: ['192.168.1.0/24'], locationName: 'test_location', - },] + }], }); new route53.ARecord(this, 'CidrRoutingConfig', { From 6b1101abd9c639f232e7f0ded0509d9850bc1216 Mon Sep 17 00:00:00 2001 From: tttol Date: Fri, 2 May 2025 10:09:16 +0900 Subject: [PATCH 11/20] fix UT --- packages/aws-cdk-lib/aws-route53/test/record-set.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts index a16e5ac4cf91e..dda61424d84f7 100644 --- a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts @@ -1456,6 +1456,12 @@ describe('record set', () => { { multiValueAnswer: true, region: 'us-east-1' }, { multiValueAnswer: true, weight: 20 }, { weight: 20, geoLocation: route53.GeoLocation.continent(route53.Continent.EUROPE), region: 'us-east-1', multiValueAnswer: true }, + { + cidrRoutingConfig: route53.CidrRoutingConfig.new({ + collectionId: '12345678-1234-1234-1234-123456789012', + locationName: 'test_location', + }), + }, ])('throw error for the simultaneous definition of weight, geoLocation and region', (props) => { // GIVEN const stack = new Stack(); @@ -1470,7 +1476,7 @@ describe('record set', () => { target: route53.RecordTarget.fromValues('zzz'), setIdentifier: 'uniqueId', ...props, - })).toThrow('Only one of region, weight, multiValueAnswer or geoLocation can be defined'); + })).toThrow('Only one of region, weight, multiValueAnswer, geoLocation or cidrRoutingConfig can be defined'); }); test('throw error for the definition of setIdentifier without weight, geoLocation or region', () => { From 43f071f22947dacfdfef7504afafcdbaabf9eac1 Mon Sep 17 00:00:00 2001 From: tttol Date: Fri, 2 May 2025 11:22:04 +0900 Subject: [PATCH 12/20] fix UT --- packages/aws-cdk-lib/aws-route53/test/record-set.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts index dda61424d84f7..c889444e1f7b7 100644 --- a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts @@ -1457,12 +1457,13 @@ describe('record set', () => { { multiValueAnswer: true, weight: 20 }, { weight: 20, geoLocation: route53.GeoLocation.continent(route53.Continent.EUROPE), region: 'us-east-1', multiValueAnswer: true }, { + weight: 20, cidrRoutingConfig: route53.CidrRoutingConfig.new({ collectionId: '12345678-1234-1234-1234-123456789012', locationName: 'test_location', }), }, - ])('throw error for the simultaneous definition of weight, geoLocation and region', (props) => { + ])('throw error for the simultaneous definition of weight, geoLocation, region, multiValueAnswer and cidrRoutingConfig', (props) => { // GIVEN const stack = new Stack(); From c89aebf3f5a0bea7178bd3589b3512856fc46fc5 Mon Sep 17 00:00:00 2001 From: tttol Date: Fri, 2 May 2025 11:54:47 +0900 Subject: [PATCH 13/20] fix README --- packages/aws-cdk-lib/aws-route53/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index 60ff139bef54c..2faff7f326bfa 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -207,7 +207,7 @@ new route53.ARecord(this, 'ARecordMultiValue1', { To enable [IP-based routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-ipbased.html), use the `cidrRoutingConfig` parameter: ```ts -declare const myZone: route53.HostedZone; +declare const zone: route53.HostedZone; const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { name: 'test-collection', From 0cd648aee7bd49dca6534f8330a7b68824e6d512 Mon Sep 17 00:00:00 2001 From: tttol Date: Mon, 5 May 2025 07:11:11 +0900 Subject: [PATCH 14/20] add method for a default CIDR record --- .../CidrRoutingConfig.assets.json | 4 +- .../CidrRoutingConfig.template.json | 44 ++++++++++++ .../manifest.json | 72 +++++++++++++++++-- .../tree.json | 2 +- .../test/integ.cidr-routing-config.ts | 25 ++++++- .../aws-route53/lib/cidr-routing-config.ts | 12 ++++ .../test/cidr-routing-config.test.ts | 16 +++++ 7 files changed, 165 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json index 46c319d766317..8fa8912ccacbd 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.assets.json @@ -1,7 +1,7 @@ { "version": "41.0.0", "files": { - "55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54": { + "ddb525b069cf7408ac8f519da5d0e35afec15ef8cedf0438e9edbeae71c21079": { "displayName": "CidrRoutingConfig Template", "source": { "path": "CidrRoutingConfig.template.json", @@ -10,7 +10,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54.json", + "objectKey": "ddb525b069cf7408ac8f519da5d0e35afec15ef8cedf0438e9edbeae71c21079.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json index 0ef3bf37322cf..9ec216cf1f739 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/CidrRoutingConfig.template.json @@ -43,6 +43,50 @@ "TTL": "1800", "Type": "A" } + }, + "HostedZone280C0117C": { + "Type": "AWS::Route53::HostedZone", + "Properties": { + "Name": "cdk.test2." + } + }, + "DefaultCidrCollection": { + "Type": "AWS::Route53::CidrCollection", + "Properties": { + "Locations": [ + { + "CidrList": [ + "192.168.1.0/24" + ], + "LocationName": "default_location" + } + ], + "Name": "default-collection" + } + }, + "DefaultCidrRoutingConfigF2FD2A05": { + "Type": "AWS::Route53::RecordSet", + "Properties": { + "CidrRoutingConfig": { + "CollectionId": { + "Fn::GetAtt": [ + "DefaultCidrCollection", + "Id" + ] + }, + "LocationName": "*" + }, + "HostedZoneId": { + "Ref": "HostedZone280C0117C" + }, + "Name": "cdk.test2.", + "ResourceRecords": [ + "5.6.7.8" + ], + "SetIdentifier": "test2", + "TTL": "1800", + "Type": "A" + } } }, "Parameters": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json index 39241c5672b50..5e3d586538fe8 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/55319b0ec2be0792760090e536d97fd785f29ddd7f8191dacb8b9838540b8e54.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ddb525b069cf7408ac8f519da5d0e35afec15ef8cedf0438e9edbeae71c21079.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -37,11 +37,15 @@ "/CidrRoutingConfig/HostedZone": [ { "type": "aws:cdk:analytics:construct", - "data": "*" + "data": { + "zoneName": "*" + } }, { "type": "aws:cdk:analytics:construct", - "data": "*" + "data": { + "zoneName": "*" + } } ], "/CidrRoutingConfig/HostedZone/Resource": [ @@ -59,11 +63,19 @@ "/CidrRoutingConfig/CidrRoutingConfig": [ { "type": "aws:cdk:analytics:construct", - "data": "*" + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } }, { "type": "aws:cdk:analytics:construct", - "data": "*" + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } } ], "/CidrRoutingConfig/CidrRoutingConfig/Resource": [ @@ -72,6 +84,56 @@ "data": "CidrRoutingConfig2AF5DEDB" } ], + "/CidrRoutingConfig/HostedZone2": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "zoneName": "*" + } + }, + { + "type": "aws:cdk:analytics:construct", + "data": { + "zoneName": "*" + } + } + ], + "/CidrRoutingConfig/HostedZone2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HostedZone280C0117C" + } + ], + "/CidrRoutingConfig/DefaultCidrCollection": [ + { + "type": "aws:cdk:logicalId", + "data": "DefaultCidrCollection" + } + ], + "/CidrRoutingConfig/DefaultCidrRoutingConfig": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } + }, + { + "type": "aws:cdk:analytics:construct", + "data": { + "zone": "*", + "target": "*", + "setIdentifier": "*" + } + } + ], + "/CidrRoutingConfig/DefaultCidrRoutingConfig/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "DefaultCidrRoutingConfigF2FD2A05" + } + ], "/CidrRoutingConfig/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json index 2b7761b7f6269..0ea04e6c2f523 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.js.snapshot/tree.json @@ -1 +1 @@ -{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig","children":{"HostedZone":{"id":"HostedZone","path":"CidrRoutingConfig/HostedZone","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test."}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2","metadata":["*","*"]}},"CidrCollection":{"id":"CidrCollection","path":"CidrRoutingConfig/CidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"test_location"}],"name":"test-collection"}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig/CidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/CidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["CidrCollection","Id"]},"locationName":"test_location"},"hostedZoneId":{"Ref":"HostedZoneDB99F866"},"name":"cdk.test.","resourceRecords":["1.2.3.4"],"setIdentifier":"test","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2","metadata":["*","*"]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfig/BootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfig/CheckBootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CidrRoutingConfigInteg":{"id":"CidrRoutingConfigInteg","path":"CidrRoutingConfigInteg","children":{"DefaultTest":{"id":"DefaultTest","path":"CidrRoutingConfigInteg/DefaultTest","children":{"Default":{"id":"Default","path":"CidrRoutingConfigInteg/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}} \ No newline at end of file +{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig","children":{"HostedZone":{"id":"HostedZone","path":"CidrRoutingConfig/HostedZone","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test."}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnHostedZone","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.PublicHostedZone","version":"0.0.0","metadata":[{"zoneName":"*"},{"zoneName":"*"}]}},"CidrCollection":{"id":"CidrCollection","path":"CidrRoutingConfig/CidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"test_location"}],"name":"test-collection"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnCidrCollection","version":"0.0.0"}},"CidrRoutingConfig":{"id":"CidrRoutingConfig","path":"CidrRoutingConfig/CidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/CidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["CidrCollection","Id"]},"locationName":"test_location"},"hostedZoneId":{"Ref":"HostedZoneDB99F866"},"name":"cdk.test.","resourceRecords":["1.2.3.4"],"setIdentifier":"test","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnRecordSet","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.ARecord","version":"0.0.0","metadata":[{"zone":"*","target":"*","setIdentifier":"*"},{"zone":"*","target":"*","setIdentifier":"*"}]}},"HostedZone2":{"id":"HostedZone2","path":"CidrRoutingConfig/HostedZone2","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/HostedZone2/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::HostedZone","aws:cdk:cloudformation:props":{"name":"cdk.test2."}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnHostedZone","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.PublicHostedZone","version":"0.0.0","metadata":[{"zoneName":"*"},{"zoneName":"*"}]}},"DefaultCidrCollection":{"id":"DefaultCidrCollection","path":"CidrRoutingConfig/DefaultCidrCollection","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::CidrCollection","aws:cdk:cloudformation:props":{"locations":[{"cidrList":["192.168.1.0/24"],"locationName":"default_location"}],"name":"default-collection"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnCidrCollection","version":"0.0.0"}},"DefaultCidrRoutingConfig":{"id":"DefaultCidrRoutingConfig","path":"CidrRoutingConfig/DefaultCidrRoutingConfig","children":{"Resource":{"id":"Resource","path":"CidrRoutingConfig/DefaultCidrRoutingConfig/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::Route53::RecordSet","aws:cdk:cloudformation:props":{"cidrRoutingConfig":{"collectionId":{"Fn::GetAtt":["DefaultCidrCollection","Id"]},"locationName":"*"},"hostedZoneId":{"Ref":"HostedZone280C0117C"},"name":"cdk.test2.","resourceRecords":["5.6.7.8"],"setIdentifier":"test2","ttl":"1800","type":"A"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.CfnRecordSet","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_route53.ARecord","version":"0.0.0","metadata":[{"zone":"*","target":"*","setIdentifier":"*"},{"zone":"*","target":"*","setIdentifier":"*"}]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfig/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfig/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}},"CidrRoutingConfigInteg":{"id":"CidrRoutingConfigInteg","path":"CidrRoutingConfigInteg","children":{"DefaultTest":{"id":"DefaultTest","path":"CidrRoutingConfigInteg/DefaultTest","children":{"Default":{"id":"Default","path":"CidrRoutingConfigInteg/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"CidrRoutingConfigInteg/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"}}} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index 2a649c15d0d0a..a18c11272cde3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -7,7 +7,7 @@ class TestStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); - const zone = new route53.PublicHostedZone(this, 'HostedZone', { + const zone1 = new route53.PublicHostedZone(this, 'HostedZone', { zoneName: 'cdk.test', }); @@ -20,7 +20,7 @@ class TestStack extends Stack { }); new route53.ARecord(this, 'CidrRoutingConfig', { - zone: zone, + zone: zone1, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', cidrRoutingConfig: route53.CidrRoutingConfig.new({ @@ -28,6 +28,27 @@ class TestStack extends Stack { locationName: 'test_location', }), }); + + const zone2 = new route53.PublicHostedZone(this, 'HostedZone2', { + zoneName: 'cdk.test2', + }); + + const defaultCidrCollection = new route53.CfnCidrCollection(this, 'DefaultCidrCollection', { + name: 'default-collection', + locations: [ + { + cidrList: ['192.168.1.0/24'], + locationName: 'default_location', + }, + ], + }); + + new route53.ARecord(this, 'DefaultCidrRoutingConfig', { + zone: zone2, + target: route53.RecordTarget.fromIpAddresses('5.6.7.8'), + setIdentifier: 'test2', + cidrRoutingConfig: route53.CidrRoutingConfig.default(defaultCidrCollection.attrId), + }); } } diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index c4cd6a89d74e3..6e9d2c61a34f0 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -28,6 +28,18 @@ export class CidrRoutingConfig { return new CidrRoutingConfig(props); } + /** + * Creates a new instance of CidrRoutingConfig for default CIDR record. This method defines the locationName as `*`. + * @param collectionId The CIDR collection ID. + * @returns A new instance of CidrRoutingConfig with the default location name as `*`. + */ + public static default(collectionId: string): CidrRoutingConfig { + return new CidrRoutingConfig({ + collectionId: collectionId, + locationName: '*', + }); + } + /** * The CIDR collection ID. */ diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index f264cec6dce36..62cf16375756e 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -79,4 +79,20 @@ describe('CidrRoutingConfig', () => { }).toThrow(expectedError); }); }); + + describe('default method', () => { + test('creates config with default locationName as *', () => { + const collectionId = '12345678-1234-1234-1234-123456789012'; + const config = CidrRoutingConfig.default(collectionId); + // Check collectionId + expect(config.collectionId).toBe(collectionId); + // Check locationName is '*' + expect(config.locationName).toBe('*'); + }); + test('throws error if collectionId is invalid', () => { + expect(() => { + CidrRoutingConfig.default('invalid-uuid'); + }).toThrow('collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)'); + }); + }); }); From 84b1aaa8be61f597826adbd5ddb3e0f581b15e80 Mon Sep 17 00:00:00 2001 From: tttol Date: Wed, 7 May 2025 06:52:09 +0900 Subject: [PATCH 15/20] update for PR comments --- .../test/integ.cidr-routing-config.ts | 1 - packages/aws-cdk-lib/aws-route53/README.md | 24 +++++++++++++++++-- .../aws-route53/lib/cidr-routing-config.ts | 2 +- .../test/cidr-routing-config.test.ts | 3 +-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index a18c11272cde3..8a5b78ac4e2b2 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -58,4 +58,3 @@ const stack = new TestStack(app, 'CidrRoutingConfig'); new IntegTest(app, 'CidrRoutingConfigInteg', { testCases: [stack], }); -app.synth(); diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index 2faff7f326bfa..fa92413879994 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -207,7 +207,7 @@ new route53.ARecord(this, 'ARecordMultiValue1', { To enable [IP-based routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-ipbased.html), use the `cidrRoutingConfig` parameter: ```ts -declare const zone: route53.HostedZone; +declare const myZone: route53.HostedZone; const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { name: 'test-collection', @@ -218,7 +218,7 @@ const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { }); new route53.ARecord(this, 'CidrRoutingConfig', { - zone: zone, + zone: myZone, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', cidrRoutingConfig: route53.CidrRoutingConfig.new({ @@ -228,6 +228,26 @@ new route53.ARecord(this, 'CidrRoutingConfig', { }); ``` +To use the default CIDR record, call the `route53.CidrRoutingConfig.default`. This sets the `locationName` to `*`. The `collectionId` is still required. +```ts +declare const myZone: route53.HostedZone; + +const cidrCollection = new route53.CfnCidrCollection(this, 'CidrCollection', { + name: 'test-collection', + locations: [{ + cidrList: ['192.168.1.0/24'], + locationName: 'my_location', + }] +}); + +new route53.ARecord(this, 'DefaultCidrRoutingConfig', { + zone: myZone, + target: route53.RecordTarget.fromIpAddresses('5.6.7.8'), + setIdentifier: 'default', + cidrRoutingConfig: route53.CidrRoutingConfig.default(cidrCollection.attrId), +}); +``` + To specify a unique identifier to differentiate among multiple resource record sets that have the same combination of name and type, use the `setIdentifier` parameter: ```ts diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index 6e9d2c61a34f0..e71bab1b86935 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -56,7 +56,7 @@ export class CidrRoutingConfig { if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) { throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`); } - if (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) { + if (!Token.isUnresolved(props.locationName) && !props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) { throw new UnscopedValidationError(`locationName(${props.locationName}) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks`); } this.collectionId = props.collectionId; diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index 62cf16375756e..e2b786f5fbee6 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -1,3 +1,4 @@ +import { Token } from '../../core'; import { CidrRoutingConfig } from '../lib/cidr-routing-config'; describe('CidrRoutingConfig', () => { @@ -84,9 +85,7 @@ describe('CidrRoutingConfig', () => { test('creates config with default locationName as *', () => { const collectionId = '12345678-1234-1234-1234-123456789012'; const config = CidrRoutingConfig.default(collectionId); - // Check collectionId expect(config.collectionId).toBe(collectionId); - // Check locationName is '*' expect(config.locationName).toBe('*'); }); test('throws error if collectionId is invalid', () => { From 43a8858c328f58c2160c086ea7fe98f64115a10c Mon Sep 17 00:00:00 2001 From: tttol Date: Wed, 7 May 2025 11:59:11 +0900 Subject: [PATCH 16/20] fix for the PR comment --- .../aws-route53/lib/cidr-routing-config.ts | 2 +- .../aws-route53/test/cidr-routing-config.test.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index e71bab1b86935..470c17f6ae9b8 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -56,7 +56,7 @@ export class CidrRoutingConfig { if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) { throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`); } - if (!Token.isUnresolved(props.locationName) && !props.locationName || !LOCATION_NAME_REGEX.test(props.locationName)) { + if (!Token.isUnresolved(props.locationName) && (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName))) { throw new UnscopedValidationError(`locationName(${props.locationName}) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks`); } this.collectionId = props.collectionId; diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index e2b786f5fbee6..39facf79b3669 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -1,4 +1,4 @@ -import { Token } from '../../core'; +import { Token } from '../../core' import { CidrRoutingConfig } from '../lib/cidr-routing-config'; describe('CidrRoutingConfig', () => { @@ -94,4 +94,17 @@ describe('CidrRoutingConfig', () => { }).toThrow('collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)'); }); }); + + describe('accepts Token as collectionId or locationName', () => { + test('accepts Token as collectionId', () => { + const collectionIdToken = Token.asString({ resolve: () => 'dummy' }); // invalid UUID + const locationNameToken = Token.asString({ resolve: () => 'dummydummydummydummy' }); // more than 16 characters + const config = CidrRoutingConfig.new({ + collectionId: collectionIdToken, + locationName: locationNameToken, + }); + expect(config.collectionId).toBe(collectionIdToken); + expect(config.locationName).toBe(locationNameToken); + }); + }); }); From b50368138ac8d24fac1fa92a8ed48d68b78e906d Mon Sep 17 00:00:00 2001 From: tttol Date: Wed, 7 May 2025 12:01:59 +0900 Subject: [PATCH 17/20] typo --- .../aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index 39facf79b3669..ce0cbf5011729 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -1,4 +1,4 @@ -import { Token } from '../../core' +import { Token } from '../../core'; import { CidrRoutingConfig } from '../lib/cidr-routing-config'; describe('CidrRoutingConfig', () => { From c4b51e5cb97125458330ccc8bd2c09e7d1e07821 Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Sat, 10 May 2025 11:51:44 +0900 Subject: [PATCH 18/20] Update packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts Co-authored-by: CORBIERE Sebastien --- packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index 470c17f6ae9b8..b12016d3f0818 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -54,7 +54,7 @@ export class CidrRoutingConfig { const COLLECTION_ID_REGEX = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/; const LOCATION_NAME_REGEX = /^[0-9A-Za-z_\-\*]{1,16}$/; if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) { - throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)`); + throw new UnscopedValidationError(`collectionId(${props.collectionId}) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 hexadecimal digits)`); } if (!Token.isUnresolved(props.locationName) && (!props.locationName || !LOCATION_NAME_REGEX.test(props.locationName))) { throw new UnscopedValidationError(`locationName(${props.locationName}) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks`); From a175c61bcaf3f724abecad80b9006c21fc013570 Mon Sep 17 00:00:00 2001 From: tttol Date: Sun, 11 May 2025 06:49:20 +0900 Subject: [PATCH 19/20] fix for PR comments --- .../test/integ.cidr-routing-config.ts | 4 ++-- .../aws-route53/lib/cidr-routing-config.ts | 11 ++++++---- .../test/cidr-routing-config.test.ts | 22 +++++++++---------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts index 8a5b78ac4e2b2..ca3e34dde9a18 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.cidr-routing-config.ts @@ -23,7 +23,7 @@ class TestStack extends Stack { zone: zone1, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', - cidrRoutingConfig: route53.CidrRoutingConfig.new({ + cidrRoutingConfig: route53.CidrRoutingConfig.create({ collectionId: cidrCollection.attrId, locationName: 'test_location', }), @@ -47,7 +47,7 @@ class TestStack extends Stack { zone: zone2, target: route53.RecordTarget.fromIpAddresses('5.6.7.8'), setIdentifier: 'test2', - cidrRoutingConfig: route53.CidrRoutingConfig.default(defaultCidrCollection.attrId), + cidrRoutingConfig: route53.CidrRoutingConfig.withDefaultLocationName(defaultCidrCollection.attrId), }); } } diff --git a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts index b12016d3f0818..049fa20763164 100644 --- a/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts +++ b/packages/aws-cdk-lib/aws-route53/lib/cidr-routing-config.ts @@ -11,8 +11,10 @@ export interface CidrRoutingConfigProps { /** * The CIDR collection location name. + * + * @default `*` */ - readonly locationName: string; + readonly locationName?: string; } /** @@ -24,7 +26,7 @@ export class CidrRoutingConfig { /** * Creates a new instance of CidrRoutingConfig */ - public static new(props: CidrRoutingConfigProps): CidrRoutingConfig { + public static create(props: CidrRoutingConfigProps): CidrRoutingConfig { return new CidrRoutingConfig(props); } @@ -33,7 +35,7 @@ export class CidrRoutingConfig { * @param collectionId The CIDR collection ID. * @returns A new instance of CidrRoutingConfig with the default location name as `*`. */ - public static default(collectionId: string): CidrRoutingConfig { + public static withDefaultLocationName(collectionId: string): CidrRoutingConfig { return new CidrRoutingConfig({ collectionId: collectionId, locationName: '*', @@ -51,6 +53,7 @@ export class CidrRoutingConfig { readonly locationName: string; private constructor(props: CidrRoutingConfigProps) { + // regex from https://docs.aws.amazon.com/Route53/latest/APIReference/API_CidrRoutingConfig.html const COLLECTION_ID_REGEX = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/; const LOCATION_NAME_REGEX = /^[0-9A-Za-z_\-\*]{1,16}$/; if (!Token.isUnresolved(props.collectionId) && !COLLECTION_ID_REGEX.test(props.collectionId)) { @@ -60,6 +63,6 @@ export class CidrRoutingConfig { throw new UnscopedValidationError(`locationName(${props.locationName}) is required and must be 1-16 characters long, containing only letters, numbers, underscores, hyphens, or asterisks`); } this.collectionId = props.collectionId; - this.locationName = props.locationName; + this.locationName = props.locationName ?? '*'; } } diff --git a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts index ce0cbf5011729..af4587c4cac7c 100644 --- a/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/cidr-routing-config.test.ts @@ -3,7 +3,7 @@ import { CidrRoutingConfig } from '../lib/cidr-routing-config'; describe('CidrRoutingConfig', () => { test('creates successfully with valid parameters', () => { - const config = CidrRoutingConfig.new({ + const config = CidrRoutingConfig.create({ collectionId: '12345678-1234-1234-1234-123456789012', locationName: 'valid-location', }); @@ -24,7 +24,7 @@ describe('CidrRoutingConfig', () => { expected: 'valid_location', }, ])('$name', ({ locationName, expected }) => { - const config = CidrRoutingConfig.new({ + const config = CidrRoutingConfig.create({ collectionId: '12345678-1234-1234-1234-123456789012', locationName, }); @@ -39,7 +39,7 @@ describe('CidrRoutingConfig', () => { name: 'invalid collectionId format', collectionId: 'invalid-uuid', locationName: 'valid-location', - expectedError: 'collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', + expectedError: 'collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 hexadecimal digits)', }, { name: 'invalid locationName format', @@ -51,7 +51,7 @@ describe('CidrRoutingConfig', () => { name: 'empty collectionId', collectionId: '', locationName: 'valid-location', - expectedError: 'collectionId() is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', + expectedError: 'collectionId() is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 hexadecimal digits)', }, { name: 'empty locationName', @@ -63,7 +63,7 @@ describe('CidrRoutingConfig', () => { name: 'null collectionId', collectionId: null as any, locationName: 'valid-location', - expectedError: 'collectionId(null) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)', + expectedError: 'collectionId(null) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 hexadecimal digits)', }, { name: 'null locationName', @@ -73,7 +73,7 @@ describe('CidrRoutingConfig', () => { }, ])('$name', ({ collectionId, locationName, expectedError }) => { expect(() => { - CidrRoutingConfig.new({ + CidrRoutingConfig.create({ collectionId, locationName, }); @@ -81,17 +81,17 @@ describe('CidrRoutingConfig', () => { }); }); - describe('default method', () => { + describe('withDefaultLocationName method', () => { test('creates config with default locationName as *', () => { const collectionId = '12345678-1234-1234-1234-123456789012'; - const config = CidrRoutingConfig.default(collectionId); + const config = CidrRoutingConfig.withDefaultLocationName(collectionId); expect(config.collectionId).toBe(collectionId); expect(config.locationName).toBe('*'); }); test('throws error if collectionId is invalid', () => { expect(() => { - CidrRoutingConfig.default('invalid-uuid'); - }).toThrow('collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 digits)'); + CidrRoutingConfig.withDefaultLocationName('invalid-uuid'); + }).toThrow('collectionId(invalid-uuid) is required and must be a valid UUID in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(8-4-4-4-12 hexadecimal digits)'); }); }); @@ -99,7 +99,7 @@ describe('CidrRoutingConfig', () => { test('accepts Token as collectionId', () => { const collectionIdToken = Token.asString({ resolve: () => 'dummy' }); // invalid UUID const locationNameToken = Token.asString({ resolve: () => 'dummydummydummydummy' }); // more than 16 characters - const config = CidrRoutingConfig.new({ + const config = CidrRoutingConfig.create({ collectionId: collectionIdToken, locationName: locationNameToken, }); From fd37c6a6c4bfe8ed6398d04d42a606957cc0b46d Mon Sep 17 00:00:00 2001 From: tttol Date: Sun, 11 May 2025 08:13:48 +0900 Subject: [PATCH 20/20] chore --- packages/aws-cdk-lib/aws-route53/README.md | 4 ++-- packages/aws-cdk-lib/aws-route53/test/record-set.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-route53/README.md b/packages/aws-cdk-lib/aws-route53/README.md index fa92413879994..8444776a4a166 100644 --- a/packages/aws-cdk-lib/aws-route53/README.md +++ b/packages/aws-cdk-lib/aws-route53/README.md @@ -221,7 +221,7 @@ new route53.ARecord(this, 'CidrRoutingConfig', { zone: myZone, target: route53.RecordTarget.fromIpAddresses('1.2.3.4'), setIdentifier: 'test', - cidrRoutingConfig: route53.CidrRoutingConfig.new({ + cidrRoutingConfig: route53.CidrRoutingConfig.create({ collectionId: cidrCollection.attrId, locationName: 'test_location' }), @@ -244,7 +244,7 @@ new route53.ARecord(this, 'DefaultCidrRoutingConfig', { zone: myZone, target: route53.RecordTarget.fromIpAddresses('5.6.7.8'), setIdentifier: 'default', - cidrRoutingConfig: route53.CidrRoutingConfig.default(cidrCollection.attrId), + cidrRoutingConfig: route53.CidrRoutingConfig.withDefaultLocationName(cidrCollection.attrId), }); ``` diff --git a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts index c889444e1f7b7..a136bb6a18099 100644 --- a/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/record-set.test.ts @@ -1458,7 +1458,7 @@ describe('record set', () => { { weight: 20, geoLocation: route53.GeoLocation.continent(route53.Continent.EUROPE), region: 'us-east-1', multiValueAnswer: true }, { weight: 20, - cidrRoutingConfig: route53.CidrRoutingConfig.new({ + cidrRoutingConfig: route53.CidrRoutingConfig.create({ collectionId: '12345678-1234-1234-1234-123456789012', locationName: 'test_location', }),