Skip to content

Commit

Permalink
feat(route53): support geolocation routing (#26383)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
jumic committed Jul 24, 2023
1 parent f22bd4e commit 6bd9a2d
Show file tree
Hide file tree
Showing 13 changed files with 853 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "31.0.0",
"version": "32.0.0",
"files": {
"f9c954c8023429cbccaf7169883a3b5bb6ecd00c97f9931179eb65a405f68dd4": {
"1e880e43b77aa38d085edaa0d9718a0b2d38584b11562fbbfc3c259c42b9d8b1": {
"source": {
"path": "aws-cdk-route53-integ.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "f9c954c8023429cbccaf7169883a3b5bb6ecd00c97f9931179eb65a405f68dd4.json",
"objectKey": "1e880e43b77aa38d085edaa0d9718a0b2d38584b11562fbbfc3c259c42b9d8b1.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
"VPCPublicSubnet1SubnetB4246D30": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "VPCB9E5F0B4"
},
"AvailabilityZone": {
"Fn::Select": [
0,
Expand All @@ -44,21 +41,24 @@
"Key": "Name",
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
}
]
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCPublicSubnet1RouteTableFEE4B781": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPCB9E5F0B4"
},
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
}
]
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCPublicSubnet1RouteTableAssociation0B0896DC": {
Expand All @@ -75,12 +75,12 @@
"VPCPublicSubnet1DefaultRoute91CEF279": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "VPCIGWB7E252D3"
},
"RouteTableId": {
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
}
},
"DependsOn": [
Expand All @@ -102,15 +102,15 @@
"VPCPublicSubnet1NATGatewayE0556630": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"SubnetId": {
"Ref": "VPCPublicSubnet1SubnetB4246D30"
},
"AllocationId": {
"Fn::GetAtt": [
"VPCPublicSubnet1EIP6AD938E8",
"AllocationId"
]
},
"SubnetId": {
"Ref": "VPCPublicSubnet1SubnetB4246D30"
},
"Tags": [
{
"Key": "Name",
Expand All @@ -126,9 +126,6 @@
"VPCPrivateSubnet1Subnet8BCA10E0": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "VPCB9E5F0B4"
},
"AvailabilityZone": {
"Fn::Select": [
0,
Expand All @@ -152,21 +149,24 @@
"Key": "Name",
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
}
]
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCPrivateSubnet1RouteTableBE8A6027": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPCB9E5F0B4"
},
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
}
]
],
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
"VPCPrivateSubnet1RouteTableAssociation347902D1": {
Expand All @@ -183,12 +183,12 @@
"VPCPrivateSubnet1DefaultRouteAE1D6490": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "VPCPublicSubnet1NATGatewayE0556630"
},
"RouteTableId": {
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
}
}
},
Expand All @@ -206,11 +206,11 @@
"VPCVPCGW99B986DC": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "VPCB9E5F0B4"
},
"InternetGatewayId": {
"Ref": "VPCIGWB7E252D3"
},
"VpcId": {
"Ref": "VPCB9E5F0B4"
}
}
},
Expand All @@ -233,16 +233,16 @@
"PrivateZoneTXT83BB83CE": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "_foo.cdk.local.",
"Type": "TXT",
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "_foo.cdk.local.",
"ResourceRecords": [
"\"Bar!\"",
"\"Baz?\""
],
"TTL": "60"
"TTL": "60",
"Type": "TXT"
}
},
"PublicZone2E1C4E34": {
Expand All @@ -254,18 +254,18 @@
"PublicZonecdktestsubcdktest83558650": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "sub.cdk.test.",
"Type": "NS",
"HostedZoneId": {
"Ref": "PublicZone2E1C4E34"
},
"Name": "sub.cdk.test.",
"ResourceRecords": {
"Fn::GetAtt": [
"PublicSubZoneDBD26A0A",
"NameServers"
]
},
"TTL": "172800"
"TTL": "172800",
"Type": "NS"
}
},
"PublicSubZoneDBD26A0A": {
Expand All @@ -283,58 +283,155 @@
"CNAMEC70A2D52": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "www.cdk.local.",
"Type": "CNAME",
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "www.cdk.local.",
"ResourceRecords": [
"server"
],
"TTL": "1800"
"TTL": "1800",
"Type": "CNAME"
}
},
"ACCC8ACD5": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "test.cdk.local.",
"Type": "A",
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "test.cdk.local.",
"ResourceRecords": [
"1.2.3.4",
"5.6.7.8"
],
"TTL": "1800"
"TTL": "1800",
"Type": "A"
}
},
"GeoLocationContinentAEA331ED": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"GeoLocation": {
"ContinentCode": "EU"
},
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "geolocation.cdk.local.",
"ResourceRecords": [
"1.2.3.0",
"5.6.7.0"
],
"SetIdentifier": "GEO_CONTINENT_EU",
"TTL": "1800",
"Type": "A"
}
},
"GeoLocationCountry523431F6": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"GeoLocation": {
"CountryCode": "DE"
},
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "geolocation.cdk.local.",
"ResourceRecords": [
"1.2.3.1",
"5.6.7.1"
],
"SetIdentifier": "GEO_COUNTRY_DE",
"TTL": "1800",
"Type": "A"
}
},
"GeoLocationSubDividion2CB12CFC": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"GeoLocation": {
"CountryCode": "US",
"SubdivisionCode": "WA"
},
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "geolocation.cdk.local.",
"ResourceRecords": [
"1.2.3.2",
"5.6.7.2"
],
"SetIdentifier": "GEO_COUNTRY_US_SUBDIVISION_WA",
"TTL": "1800",
"Type": "A"
}
},
"GeoLocationSubDividionUA778564B1": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"GeoLocation": {
"CountryCode": "UA",
"SubdivisionCode": "30"
},
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "cdk.local.",
"ResourceRecords": [
"1.2.3.4",
"5.6.7.4"
],
"SetIdentifier": "GEO_COUNTRY_UA_SUBDIVISION_30",
"TTL": "1800",
"Type": "A"
}
},
"GeoLocationDefaultF2DE9058": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"GeoLocation": {
"CountryCode": "*"
},
"HostedZoneId": {
"Ref": "PrivateZone27242E85"
},
"Name": "geolocation.cdk.local.",
"ResourceRecords": [
"1.2.3.3",
"5.6.7.3"
],
"SetIdentifier": "GEO_COUNTRY_*",
"TTL": "1800",
"Type": "A"
}
},
"CaaAmazon40DF725F": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "cdk.test.",
"Type": "CAA",
"HostedZoneId": {
"Ref": "PublicZone2E1C4E34"
},
"Name": "cdk.test.",
"ResourceRecords": [
"0 issue \"amazon.com\""
],
"TTL": "1800"
"TTL": "1800",
"Type": "CAA"
}
},
"TXT0D5C5ACF": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "cdk.test.",
"Type": "TXT",
"HostedZoneId": {
"Ref": "PublicZone2E1C4E34"
},
"Name": "cdk.test.",
"ResourceRecords": [
"\"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\""
],
"TTL": "1800"
"TTL": "1800",
"Type": "TXT"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"31.0.0"}
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "31.0.0",
"version": "32.0.0",
"testCases": {
"integ.route53": {
"stacks": [
Expand Down
Loading

0 comments on commit 6bd9a2d

Please sign in to comment.