Skip to content

Commit 4f8b7db

Browse files
authored
feat: allow to register an existing record created manually as an alias ARecord target (#29565)
### Issue # (if applicable) Closes #23048. ### Reason for this change Currently an existing A record created outside of CDK cannot be registered as an Alias Target under a new A record, while this is possible through AWS console. ### Description of changes Introduces new function under class Arecord which will take input as existing record DNS name and then register it as an alias target under new Arecord. This way user will be able to alias an existing record (for type ARecord only). ### Description of how you validated changes - Added Unit tests to validate new A record is created with an alias target passed through new function - Added Integration test for the alias target validation in template and after deployment to account. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f0835d9 commit 4f8b7db

12 files changed

Lines changed: 1273 additions & 1 deletion

File tree

‎packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/AwsCdkARecordDnsIntegTestDefaultTestDeployAssert5618DC96.assets.json‎

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/AwsCdkARecordDnsIntegTestDefaultTestDeployAssert5618DC96.template.json‎

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/aws-cdk-route53-integ.assets.json‎

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
{
2+
"Resources": {
3+
"VPCB9E5F0B4": {
4+
"Type": "AWS::EC2::VPC",
5+
"Properties": {
6+
"CidrBlock": "10.0.0.0/16",
7+
"EnableDnsHostnames": true,
8+
"EnableDnsSupport": true,
9+
"InstanceTenancy": "default",
10+
"Tags": [
11+
{
12+
"Key": "Name",
13+
"Value": "aws-cdk-route53-integ/VPC"
14+
}
15+
]
16+
}
17+
},
18+
"VPCPublicSubnet1SubnetB4246D30": {
19+
"Type": "AWS::EC2::Subnet",
20+
"Properties": {
21+
"AvailabilityZone": {
22+
"Fn::Select": [
23+
0,
24+
{
25+
"Fn::GetAZs": ""
26+
}
27+
]
28+
},
29+
"CidrBlock": "10.0.0.0/17",
30+
"MapPublicIpOnLaunch": true,
31+
"Tags": [
32+
{
33+
"Key": "aws-cdk:subnet-name",
34+
"Value": "Public"
35+
},
36+
{
37+
"Key": "aws-cdk:subnet-type",
38+
"Value": "Public"
39+
},
40+
{
41+
"Key": "Name",
42+
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
43+
}
44+
],
45+
"VpcId": {
46+
"Ref": "VPCB9E5F0B4"
47+
}
48+
}
49+
},
50+
"VPCPublicSubnet1RouteTableFEE4B781": {
51+
"Type": "AWS::EC2::RouteTable",
52+
"Properties": {
53+
"Tags": [
54+
{
55+
"Key": "Name",
56+
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
57+
}
58+
],
59+
"VpcId": {
60+
"Ref": "VPCB9E5F0B4"
61+
}
62+
}
63+
},
64+
"VPCPublicSubnet1RouteTableAssociation0B0896DC": {
65+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
66+
"Properties": {
67+
"RouteTableId": {
68+
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
69+
},
70+
"SubnetId": {
71+
"Ref": "VPCPublicSubnet1SubnetB4246D30"
72+
}
73+
}
74+
},
75+
"VPCPublicSubnet1DefaultRoute91CEF279": {
76+
"Type": "AWS::EC2::Route",
77+
"Properties": {
78+
"DestinationCidrBlock": "0.0.0.0/0",
79+
"GatewayId": {
80+
"Ref": "VPCIGWB7E252D3"
81+
},
82+
"RouteTableId": {
83+
"Ref": "VPCPublicSubnet1RouteTableFEE4B781"
84+
}
85+
},
86+
"DependsOn": [
87+
"VPCVPCGW99B986DC"
88+
]
89+
},
90+
"VPCPublicSubnet1EIP6AD938E8": {
91+
"Type": "AWS::EC2::EIP",
92+
"Properties": {
93+
"Domain": "vpc",
94+
"Tags": [
95+
{
96+
"Key": "Name",
97+
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
98+
}
99+
]
100+
}
101+
},
102+
"VPCPublicSubnet1NATGatewayE0556630": {
103+
"Type": "AWS::EC2::NatGateway",
104+
"Properties": {
105+
"AllocationId": {
106+
"Fn::GetAtt": [
107+
"VPCPublicSubnet1EIP6AD938E8",
108+
"AllocationId"
109+
]
110+
},
111+
"SubnetId": {
112+
"Ref": "VPCPublicSubnet1SubnetB4246D30"
113+
},
114+
"Tags": [
115+
{
116+
"Key": "Name",
117+
"Value": "aws-cdk-route53-integ/VPC/PublicSubnet1"
118+
}
119+
]
120+
},
121+
"DependsOn": [
122+
"VPCPublicSubnet1DefaultRoute91CEF279",
123+
"VPCPublicSubnet1RouteTableAssociation0B0896DC"
124+
]
125+
},
126+
"VPCPrivateSubnet1Subnet8BCA10E0": {
127+
"Type": "AWS::EC2::Subnet",
128+
"Properties": {
129+
"AvailabilityZone": {
130+
"Fn::Select": [
131+
0,
132+
{
133+
"Fn::GetAZs": ""
134+
}
135+
]
136+
},
137+
"CidrBlock": "10.0.128.0/17",
138+
"MapPublicIpOnLaunch": false,
139+
"Tags": [
140+
{
141+
"Key": "aws-cdk:subnet-name",
142+
"Value": "Private"
143+
},
144+
{
145+
"Key": "aws-cdk:subnet-type",
146+
"Value": "Private"
147+
},
148+
{
149+
"Key": "Name",
150+
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
151+
}
152+
],
153+
"VpcId": {
154+
"Ref": "VPCB9E5F0B4"
155+
}
156+
}
157+
},
158+
"VPCPrivateSubnet1RouteTableBE8A6027": {
159+
"Type": "AWS::EC2::RouteTable",
160+
"Properties": {
161+
"Tags": [
162+
{
163+
"Key": "Name",
164+
"Value": "aws-cdk-route53-integ/VPC/PrivateSubnet1"
165+
}
166+
],
167+
"VpcId": {
168+
"Ref": "VPCB9E5F0B4"
169+
}
170+
}
171+
},
172+
"VPCPrivateSubnet1RouteTableAssociation347902D1": {
173+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
174+
"Properties": {
175+
"RouteTableId": {
176+
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
177+
},
178+
"SubnetId": {
179+
"Ref": "VPCPrivateSubnet1Subnet8BCA10E0"
180+
}
181+
}
182+
},
183+
"VPCPrivateSubnet1DefaultRouteAE1D6490": {
184+
"Type": "AWS::EC2::Route",
185+
"Properties": {
186+
"DestinationCidrBlock": "0.0.0.0/0",
187+
"NatGatewayId": {
188+
"Ref": "VPCPublicSubnet1NATGatewayE0556630"
189+
},
190+
"RouteTableId": {
191+
"Ref": "VPCPrivateSubnet1RouteTableBE8A6027"
192+
}
193+
}
194+
},
195+
"VPCIGWB7E252D3": {
196+
"Type": "AWS::EC2::InternetGateway",
197+
"Properties": {
198+
"Tags": [
199+
{
200+
"Key": "Name",
201+
"Value": "aws-cdk-route53-integ/VPC"
202+
}
203+
]
204+
}
205+
},
206+
"VPCVPCGW99B986DC": {
207+
"Type": "AWS::EC2::VPCGatewayAttachment",
208+
"Properties": {
209+
"InternetGatewayId": {
210+
"Ref": "VPCIGWB7E252D3"
211+
},
212+
"VpcId": {
213+
"Ref": "VPCB9E5F0B4"
214+
}
215+
}
216+
},
217+
"PrivateZone27242E85": {
218+
"Type": "AWS::Route53::HostedZone",
219+
"Properties": {
220+
"Name": "cdk.local.",
221+
"VPCs": [
222+
{
223+
"VPCId": {
224+
"Ref": "VPCB9E5F0B4"
225+
},
226+
"VPCRegion": {
227+
"Ref": "AWS::Region"
228+
}
229+
}
230+
]
231+
}
232+
},
233+
"AManualAC0F29BE": {
234+
"Type": "AWS::Route53::RecordSet",
235+
"Properties": {
236+
"HostedZoneId": {
237+
"Ref": "PrivateZone27242E85"
238+
},
239+
"Name": "existing.test.record.cdk.local.",
240+
"ResourceRecords": [
241+
"192.0.1.1"
242+
],
243+
"TTL": "1800",
244+
"Type": "A"
245+
}
246+
},
247+
"ACCC8ACD5": {
248+
"Type": "AWS::Route53::RecordSet",
249+
"Properties": {
250+
"AliasTarget": {
251+
"DNSName": "existing.test.record.cdk.local",
252+
"HostedZoneId": {
253+
"Ref": "PrivateZone27242E85"
254+
}
255+
},
256+
"HostedZoneId": {
257+
"Ref": "PrivateZone27242E85"
258+
},
259+
"Name": "r53-integ-test.cdk.local.",
260+
"Type": "A"
261+
},
262+
"DependsOn": [
263+
"AManualAC0F29BE"
264+
]
265+
}
266+
},
267+
"Parameters": {
268+
"BootstrapVersion": {
269+
"Type": "AWS::SSM::Parameter::Value<String>",
270+
"Default": "/cdk-bootstrap/hnb659fds/version",
271+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
272+
}
273+
},
274+
"Rules": {
275+
"CheckBootstrapVersion": {
276+
"Assertions": [
277+
{
278+
"Assert": {
279+
"Fn::Not": [
280+
{
281+
"Fn::Contains": [
282+
[
283+
"1",
284+
"2",
285+
"3",
286+
"4",
287+
"5"
288+
],
289+
{
290+
"Ref": "BootstrapVersion"
291+
}
292+
]
293+
}
294+
]
295+
},
296+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
297+
}
298+
]
299+
}
300+
}
301+
}

‎packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/cdk.out‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/@aws-cdk-testing/framework-integ/test/aws-route53/test/integ.import-existing-record-as-target.js.snapshot/integ.json‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)