Skip to content

Commit 6bd9a2d

Browse files
authored
feat(route53): support geolocation routing (#26383)
Add support for [geolocation routing](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-geo.html) in Route53 RecordSets. This PR adds attribute `geoLocation` to `RecordSetOptions` and new class `GeoLocation`. This enables developers to use geolocation routing. The new feature can be used like this (more examples in README): ```ts new route53.ARecord(this, 'ARecordGeoLocationContinent', { zone: myZone, target: route53.RecordTarget.fromIpAddresses('1.2.3.0', '5.6.7.0'), geoLocation: route53.GeoLocation.continent('EU'), // Europe }); ``` Closes #9478. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f22bd4e commit 6bd9a2d

File tree

13 files changed

+853
-101
lines changed

13 files changed

+853
-101
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.route53.js.snapshot/aws-cdk-route53-integ.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"files": {
4-
"f9c954c8023429cbccaf7169883a3b5bb6ecd00c97f9931179eb65a405f68dd4": {
4+
"1e880e43b77aa38d085edaa0d9718a0b2d38584b11562fbbfc3c259c42b9d8b1": {
55
"source": {
66
"path": "aws-cdk-route53-integ.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "f9c954c8023429cbccaf7169883a3b5bb6ecd00c97f9931179eb65a405f68dd4.json",
12+
"objectKey": "1e880e43b77aa38d085edaa0d9718a0b2d38584b11562fbbfc3c259c42b9d8b1.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.route53.js.snapshot/aws-cdk-route53-integ.template.json

+143-46
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"VPCPublicSubnet1SubnetB4246D30": {
1919
"Type": "AWS::EC2::Subnet",
2020
"Properties": {
21-
"VpcId": {
22-
"Ref": "VPCB9E5F0B4"
23-
},
2421
"AvailabilityZone": {
2522
"Fn::Select": [
2623
0,
@@ -44,21 +41,24 @@
4441
"Key": "Name",
4542
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
4643
}
47-
]
44+
],
45+
"VpcId": {
46+
"Ref": "VPCB9E5F0B4"
47+
}
4848
}
4949
},
5050
"VPCPublicSubnet1RouteTableFEE4B781": {
5151
"Type": "AWS::EC2::RouteTable",
5252
"Properties": {
53-
"VpcId": {
54-
"Ref": "VPCB9E5F0B4"
55-
},
5653
"Tags": [
5754
{
5855
"Key": "Name",
5956
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
6057
}
61-
]
58+
],
59+
"VpcId": {
60+
"Ref": "VPCB9E5F0B4"
61+
}
6262
}
6363
},
6464
"VPCPublicSubnet1RouteTableAssociation0B0896DC": {
@@ -75,12 +75,12 @@
7575
"VPCPublicSubnet1DefaultRoute91CEF279": {
7676
"Type": "AWS::EC2::Route",
7777
"Properties": {
78-
"RouteTableId": {
79-
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
80-
},
8178
"DestinationCidrBlock": "0.0.0.0/0",
8279
"GatewayId": {
8380
"Ref": "VPCIGWB7E252D3"
81+
},
82+
"RouteTableId": {
83+
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
8484
}
8585
},
8686
"DependsOn": [
@@ -102,15 +102,15 @@
102102
"VPCPublicSubnet1NATGatewayE0556630": {
103103
"Type": "AWS::EC2::NatGateway",
104104
"Properties": {
105-
"SubnetId": {
106-
"Ref": "VPCPublicSubnet1SubnetB4246D30"
107-
},
108105
"AllocationId": {
109106
"Fn::GetAtt": [
110107
"VPCPublicSubnet1EIP6AD938E8",
111108
"AllocationId"
112109
]
113110
},
111+
"SubnetId": {
112+
"Ref": "VPCPublicSubnet1SubnetB4246D30"
113+
},
114114
"Tags": [
115115
{
116116
"Key": "Name",
@@ -126,9 +126,6 @@
126126
"VPCPrivateSubnet1Subnet8BCA10E0": {
127127
"Type": "AWS::EC2::Subnet",
128128
"Properties": {
129-
"VpcId": {
130-
"Ref": "VPCB9E5F0B4"
131-
},
132129
"AvailabilityZone": {
133130
"Fn::Select": [
134131
0,
@@ -152,21 +149,24 @@
152149
"Key": "Name",
153150
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
154151
}
155-
]
152+
],
153+
"VpcId": {
154+
"Ref": "VPCB9E5F0B4"
155+
}
156156
}
157157
},
158158
"VPCPrivateSubnet1RouteTableBE8A6027": {
159159
"Type": "AWS::EC2::RouteTable",
160160
"Properties": {
161-
"VpcId": {
162-
"Ref": "VPCB9E5F0B4"
163-
},
164161
"Tags": [
165162
{
166163
"Key": "Name",
167164
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
168165
}
169-
]
166+
],
167+
"VpcId": {
168+
"Ref": "VPCB9E5F0B4"
169+
}
170170
}
171171
},
172172
"VPCPrivateSubnet1RouteTableAssociation347902D1": {
@@ -183,12 +183,12 @@
183183
"VPCPrivateSubnet1DefaultRouteAE1D6490": {
184184
"Type": "AWS::EC2::Route",
185185
"Properties": {
186-
"RouteTableId": {
187-
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
188-
},
189186
"DestinationCidrBlock": "0.0.0.0/0",
190187
"NatGatewayId": {
191188
"Ref": "VPCPublicSubnet1NATGatewayE0556630"
189+
},
190+
"RouteTableId": {
191+
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
192192
}
193193
}
194194
},
@@ -206,11 +206,11 @@
206206
"VPCVPCGW99B986DC": {
207207
"Type": "AWS::EC2::VPCGatewayAttachment",
208208
"Properties": {
209-
"VpcId": {
210-
"Ref": "VPCB9E5F0B4"
211-
},
212209
"InternetGatewayId": {
213210
"Ref": "VPCIGWB7E252D3"
211+
},
212+
"VpcId": {
213+
"Ref": "VPCB9E5F0B4"
214214
}
215215
}
216216
},
@@ -233,16 +233,16 @@
233233
"PrivateZoneTXT83BB83CE": {
234234
"Type": "AWS::Route53::RecordSet",
235235
"Properties": {
236-
"Name": "_foo.cdk.local.",
237-
"Type": "TXT",
238236
"HostedZoneId": {
239237
"Ref": "PrivateZone27242E85"
240238
},
239+
"Name": "_foo.cdk.local.",
241240
"ResourceRecords": [
242241
"\"Bar!\"",
243242
"\"Baz?\""
244243
],
245-
"TTL": "60"
244+
"TTL": "60",
245+
"Type": "TXT"
246246
}
247247
},
248248
"PublicZone2E1C4E34": {
@@ -254,18 +254,18 @@
254254
"PublicZonecdktestsubcdktest83558650": {
255255
"Type": "AWS::Route53::RecordSet",
256256
"Properties": {
257-
"Name": "sub.cdk.test.",
258-
"Type": "NS",
259257
"HostedZoneId": {
260258
"Ref": "PublicZone2E1C4E34"
261259
},
260+
"Name": "sub.cdk.test.",
262261
"ResourceRecords": {
263262
"Fn::GetAtt": [
264263
"PublicSubZoneDBD26A0A",
265264
"NameServers"
266265
]
267266
},
268-
"TTL": "172800"
267+
"TTL": "172800",
268+
"Type": "NS"
269269
}
270270
},
271271
"PublicSubZoneDBD26A0A": {
@@ -283,58 +283,155 @@
283283
"CNAMEC70A2D52": {
284284
"Type": "AWS::Route53::RecordSet",
285285
"Properties": {
286-
"Name": "www.cdk.local.",
287-
"Type": "CNAME",
288286
"HostedZoneId": {
289287
"Ref": "PrivateZone27242E85"
290288
},
289+
"Name": "www.cdk.local.",
291290
"ResourceRecords": [
292291
"server"
293292
],
294-
"TTL": "1800"
293+
"TTL": "1800",
294+
"Type": "CNAME"
295295
}
296296
},
297297
"ACCC8ACD5": {
298298
"Type": "AWS::Route53::RecordSet",
299299
"Properties": {
300-
"Name": "test.cdk.local.",
301-
"Type": "A",
302300
"HostedZoneId": {
303301
"Ref": "PrivateZone27242E85"
304302
},
303+
"Name": "test.cdk.local.",
305304
"ResourceRecords": [
306305
"1.2.3.4",
307306
"5.6.7.8"
308307
],
309-
"TTL": "1800"
308+
"TTL": "1800",
309+
"Type": "A"
310+
}
311+
},
312+
"GeoLocationContinentAEA331ED": {
313+
"Type": "AWS::Route53::RecordSet",
314+
"Properties": {
315+
"GeoLocation": {
316+
"ContinentCode": "EU"
317+
},
318+
"HostedZoneId": {
319+
"Ref": "PrivateZone27242E85"
320+
},
321+
"Name": "geolocation.cdk.local.",
322+
"ResourceRecords": [
323+
"1.2.3.0",
324+
"5.6.7.0"
325+
],
326+
"SetIdentifier": "GEO_CONTINENT_EU",
327+
"TTL": "1800",
328+
"Type": "A"
329+
}
330+
},
331+
"GeoLocationCountry523431F6": {
332+
"Type": "AWS::Route53::RecordSet",
333+
"Properties": {
334+
"GeoLocation": {
335+
"CountryCode": "DE"
336+
},
337+
"HostedZoneId": {
338+
"Ref": "PrivateZone27242E85"
339+
},
340+
"Name": "geolocation.cdk.local.",
341+
"ResourceRecords": [
342+
"1.2.3.1",
343+
"5.6.7.1"
344+
],
345+
"SetIdentifier": "GEO_COUNTRY_DE",
346+
"TTL": "1800",
347+
"Type": "A"
348+
}
349+
},
350+
"GeoLocationSubDividion2CB12CFC": {
351+
"Type": "AWS::Route53::RecordSet",
352+
"Properties": {
353+
"GeoLocation": {
354+
"CountryCode": "US",
355+
"SubdivisionCode": "WA"
356+
},
357+
"HostedZoneId": {
358+
"Ref": "PrivateZone27242E85"
359+
},
360+
"Name": "geolocation.cdk.local.",
361+
"ResourceRecords": [
362+
"1.2.3.2",
363+
"5.6.7.2"
364+
],
365+
"SetIdentifier": "GEO_COUNTRY_US_SUBDIVISION_WA",
366+
"TTL": "1800",
367+
"Type": "A"
368+
}
369+
},
370+
"GeoLocationSubDividionUA778564B1": {
371+
"Type": "AWS::Route53::RecordSet",
372+
"Properties": {
373+
"GeoLocation": {
374+
"CountryCode": "UA",
375+
"SubdivisionCode": "30"
376+
},
377+
"HostedZoneId": {
378+
"Ref": "PrivateZone27242E85"
379+
},
380+
"Name": "cdk.local.",
381+
"ResourceRecords": [
382+
"1.2.3.4",
383+
"5.6.7.4"
384+
],
385+
"SetIdentifier": "GEO_COUNTRY_UA_SUBDIVISION_30",
386+
"TTL": "1800",
387+
"Type": "A"
388+
}
389+
},
390+
"GeoLocationDefaultF2DE9058": {
391+
"Type": "AWS::Route53::RecordSet",
392+
"Properties": {
393+
"GeoLocation": {
394+
"CountryCode": "*"
395+
},
396+
"HostedZoneId": {
397+
"Ref": "PrivateZone27242E85"
398+
},
399+
"Name": "geolocation.cdk.local.",
400+
"ResourceRecords": [
401+
"1.2.3.3",
402+
"5.6.7.3"
403+
],
404+
"SetIdentifier": "GEO_COUNTRY_*",
405+
"TTL": "1800",
406+
"Type": "A"
310407
}
311408
},
312409
"CaaAmazon40DF725F": {
313410
"Type": "AWS::Route53::RecordSet",
314411
"Properties": {
315-
"Name": "cdk.test.",
316-
"Type": "CAA",
317412
"HostedZoneId": {
318413
"Ref": "PublicZone2E1C4E34"
319414
},
415+
"Name": "cdk.test.",
320416
"ResourceRecords": [
321417
"0 issue \"amazon.com\""
322418
],
323-
"TTL": "1800"
419+
"TTL": "1800",
420+
"Type": "CAA"
324421
}
325422
},
326423
"TXT0D5C5ACF": {
327424
"Type": "AWS::Route53::RecordSet",
328425
"Properties": {
329-
"Name": "cdk.test.",
330-
"Type": "TXT",
331426
"HostedZoneId": {
332427
"Ref": "PublicZone2E1C4E34"
333428
},
429+
"Name": "cdk.test.",
334430
"ResourceRecords": [
335431
"\"this is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long stringthis is a very long s\"\"tring\""
336432
],
337-
"TTL": "1800"
433+
"TTL": "1800",
434+
"Type": "TXT"
338435
}
339436
}
340437
},
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"31.0.0"}
1+
{"version":"32.0.0"}

packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.route53.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"testCases": {
44
"integ.route53": {
55
"stacks": [

0 commit comments

Comments
 (0)