Skip to content

Commit 7f31da8

Browse files
authored
fix(ec2): networkAclName property for NetworkAcl does not work (#26898)
Currently, networkAclName property for NetworkAcl L2 is never referred in generated CloudFormation template. This PR solves the issue by adding Name tag with the value of networkAclName property. This fix is similar to #26371 Closes #26897 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1cead3b commit 7f31da8

File tree

9 files changed

+290
-240
lines changed

9 files changed

+290
-240
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-networkacl.js.snapshot/aws-cdk-ec2-vpc.assets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "20.0.0",
2+
"version": "34.0.0",
33
"files": {
4-
"04eb43593fbbe54e6eadc94dac3e2388aa1e9ef1bac4156293e7b6e2363b5bb4": {
4+
"deb6adbcfa8931cee9545cb210604a66e240d637bdf67fca383fe3f17d220ae1": {
55
"source": {
66
"path": "aws-cdk-ec2-vpc.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "04eb43593fbbe54e6eadc94dac3e2388aa1e9ef1bac4156293e7b6e2363b5bb4.json",
12+
"objectKey": "deb6adbcfa8931cee9545cb210604a66e240d637bdf67fca383fe3f17d220ae1.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-ec2/test/integ.vpc-networkacl.js.snapshot/aws-cdk-ec2-vpc.template.json

Lines changed: 71 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"MyVpcPublicSubnet1SubnetF6608456": {
1919
"Type": "AWS::EC2::Subnet",
2020
"Properties": {
21-
"VpcId": {
22-
"Ref": "MyVpcF9F0CA6F"
23-
},
2421
"AvailabilityZone": {
2522
"Fn::Select": [
2623
0,
@@ -44,21 +41,24 @@
4441
"Key": "Name",
4542
"Value": "aws-cdk-ec2-vpc/MyVpc/PublicSubnet1"
4643
}
47-
]
44+
],
45+
"VpcId": {
46+
"Ref": "MyVpcF9F0CA6F"
47+
}
4848
}
4949
},
5050
"MyVpcPublicSubnet1RouteTableC46AB2F4": {
5151
"Type": "AWS::EC2::RouteTable",
5252
"Properties": {
53-
"VpcId": {
54-
"Ref": "MyVpcF9F0CA6F"
55-
},
5653
"Tags": [
5754
{
5855
"Key": "Name",
5956
"Value": "aws-cdk-ec2-vpc/MyVpc/PublicSubnet1"
6057
}
61-
]
58+
],
59+
"VpcId": {
60+
"Ref": "MyVpcF9F0CA6F"
61+
}
6262
}
6363
},
6464
"MyVpcPublicSubnet1RouteTableAssociation2ECEE1CB": {
@@ -75,12 +75,12 @@
7575
"MyVpcPublicSubnet1DefaultRoute95FDF9EB": {
7676
"Type": "AWS::EC2::Route",
7777
"Properties": {
78-
"RouteTableId": {
79-
"Ref": "MyVpcPublicSubnet1RouteTableC46AB2F4"
80-
},
8178
"DestinationCidrBlock": "0.0.0.0/0",
8279
"GatewayId": {
8380
"Ref": "MyVpcIGW5C4A4F63"
81+
},
82+
"RouteTableId": {
83+
"Ref": "MyVpcPublicSubnet1RouteTableC46AB2F4"
8484
}
8585
},
8686
"DependsOn": [
@@ -102,15 +102,15 @@
102102
"MyVpcPublicSubnet1NATGatewayAD3400C1": {
103103
"Type": "AWS::EC2::NatGateway",
104104
"Properties": {
105-
"SubnetId": {
106-
"Ref": "MyVpcPublicSubnet1SubnetF6608456"
107-
},
108105
"AllocationId": {
109106
"Fn::GetAtt": [
110107
"MyVpcPublicSubnet1EIP096967CB",
111108
"AllocationId"
112109
]
113110
},
111+
"SubnetId": {
112+
"Ref": "MyVpcPublicSubnet1SubnetF6608456"
113+
},
114114
"Tags": [
115115
{
116116
"Key": "Name",
@@ -126,9 +126,6 @@
126126
"MyVpcPublicSubnet2Subnet492B6BFB": {
127127
"Type": "AWS::EC2::Subnet",
128128
"Properties": {
129-
"VpcId": {
130-
"Ref": "MyVpcF9F0CA6F"
131-
},
132129
"AvailabilityZone": {
133130
"Fn::Select": [
134131
1,
@@ -152,21 +149,24 @@
152149
"Key": "Name",
153150
"Value": "aws-cdk-ec2-vpc/MyVpc/PublicSubnet2"
154151
}
155-
]
152+
],
153+
"VpcId": {
154+
"Ref": "MyVpcF9F0CA6F"
155+
}
156156
}
157157
},
158158
"MyVpcPublicSubnet2RouteTable1DF17386": {
159159
"Type": "AWS::EC2::RouteTable",
160160
"Properties": {
161-
"VpcId": {
162-
"Ref": "MyVpcF9F0CA6F"
163-
},
164161
"Tags": [
165162
{
166163
"Key": "Name",
167164
"Value": "aws-cdk-ec2-vpc/MyVpc/PublicSubnet2"
168165
}
169-
]
166+
],
167+
"VpcId": {
168+
"Ref": "MyVpcF9F0CA6F"
169+
}
170170
}
171171
},
172172
"MyVpcPublicSubnet2RouteTableAssociation227DE78D": {
@@ -183,12 +183,12 @@
183183
"MyVpcPublicSubnet2DefaultRoute052936F6": {
184184
"Type": "AWS::EC2::Route",
185185
"Properties": {
186-
"RouteTableId": {
187-
"Ref": "MyVpcPublicSubnet2RouteTable1DF17386"
188-
},
189186
"DestinationCidrBlock": "0.0.0.0/0",
190187
"GatewayId": {
191188
"Ref": "MyVpcIGW5C4A4F63"
189+
},
190+
"RouteTableId": {
191+
"Ref": "MyVpcPublicSubnet2RouteTable1DF17386"
192192
}
193193
},
194194
"DependsOn": [
@@ -210,15 +210,15 @@
210210
"MyVpcPublicSubnet2NATGateway91BFBEC9": {
211211
"Type": "AWS::EC2::NatGateway",
212212
"Properties": {
213-
"SubnetId": {
214-
"Ref": "MyVpcPublicSubnet2Subnet492B6BFB"
215-
},
216213
"AllocationId": {
217214
"Fn::GetAtt": [
218215
"MyVpcPublicSubnet2EIP8CCBA239",
219216
"AllocationId"
220217
]
221218
},
219+
"SubnetId": {
220+
"Ref": "MyVpcPublicSubnet2Subnet492B6BFB"
221+
},
222222
"Tags": [
223223
{
224224
"Key": "Name",
@@ -234,9 +234,6 @@
234234
"MyVpcPrivateSubnet1Subnet5057CF7E": {
235235
"Type": "AWS::EC2::Subnet",
236236
"Properties": {
237-
"VpcId": {
238-
"Ref": "MyVpcF9F0CA6F"
239-
},
240237
"AvailabilityZone": {
241238
"Fn::Select": [
242239
0,
@@ -260,21 +257,24 @@
260257
"Key": "Name",
261258
"Value": "aws-cdk-ec2-vpc/MyVpc/PrivateSubnet1"
262259
}
263-
]
260+
],
261+
"VpcId": {
262+
"Ref": "MyVpcF9F0CA6F"
263+
}
264264
}
265265
},
266266
"MyVpcPrivateSubnet1RouteTable8819E6E2": {
267267
"Type": "AWS::EC2::RouteTable",
268268
"Properties": {
269-
"VpcId": {
270-
"Ref": "MyVpcF9F0CA6F"
271-
},
272269
"Tags": [
273270
{
274271
"Key": "Name",
275272
"Value": "aws-cdk-ec2-vpc/MyVpc/PrivateSubnet1"
276273
}
277-
]
274+
],
275+
"VpcId": {
276+
"Ref": "MyVpcF9F0CA6F"
277+
}
278278
}
279279
},
280280
"MyVpcPrivateSubnet1RouteTableAssociation56D38C7E": {
@@ -291,21 +291,18 @@
291291
"MyVpcPrivateSubnet1DefaultRouteA8CDE2FA": {
292292
"Type": "AWS::EC2::Route",
293293
"Properties": {
294-
"RouteTableId": {
295-
"Ref": "MyVpcPrivateSubnet1RouteTable8819E6E2"
296-
},
297294
"DestinationCidrBlock": "0.0.0.0/0",
298295
"NatGatewayId": {
299296
"Ref": "MyVpcPublicSubnet1NATGatewayAD3400C1"
297+
},
298+
"RouteTableId": {
299+
"Ref": "MyVpcPrivateSubnet1RouteTable8819E6E2"
300300
}
301301
}
302302
},
303303
"MyVpcPrivateSubnet2Subnet0040C983": {
304304
"Type": "AWS::EC2::Subnet",
305305
"Properties": {
306-
"VpcId": {
307-
"Ref": "MyVpcF9F0CA6F"
308-
},
309306
"AvailabilityZone": {
310307
"Fn::Select": [
311308
1,
@@ -329,21 +326,24 @@
329326
"Key": "Name",
330327
"Value": "aws-cdk-ec2-vpc/MyVpc/PrivateSubnet2"
331328
}
332-
]
329+
],
330+
"VpcId": {
331+
"Ref": "MyVpcF9F0CA6F"
332+
}
333333
}
334334
},
335335
"MyVpcPrivateSubnet2RouteTableCEDCEECE": {
336336
"Type": "AWS::EC2::RouteTable",
337337
"Properties": {
338-
"VpcId": {
339-
"Ref": "MyVpcF9F0CA6F"
340-
},
341338
"Tags": [
342339
{
343340
"Key": "Name",
344341
"Value": "aws-cdk-ec2-vpc/MyVpc/PrivateSubnet2"
345342
}
346-
]
343+
],
344+
"VpcId": {
345+
"Ref": "MyVpcF9F0CA6F"
346+
}
347347
}
348348
},
349349
"MyVpcPrivateSubnet2RouteTableAssociation86A610DA": {
@@ -360,12 +360,12 @@
360360
"MyVpcPrivateSubnet2DefaultRoute9CE96294": {
361361
"Type": "AWS::EC2::Route",
362362
"Properties": {
363-
"RouteTableId": {
364-
"Ref": "MyVpcPrivateSubnet2RouteTableCEDCEECE"
365-
},
366363
"DestinationCidrBlock": "0.0.0.0/0",
367364
"NatGatewayId": {
368365
"Ref": "MyVpcPublicSubnet2NATGateway91BFBEC9"
366+
},
367+
"RouteTableId": {
368+
"Ref": "MyVpcPrivateSubnet2RouteTableCEDCEECE"
369369
}
370370
}
371371
},
@@ -383,17 +383,23 @@
383383
"MyVpcVPCGW488ACE0D": {
384384
"Type": "AWS::EC2::VPCGatewayAttachment",
385385
"Properties": {
386-
"VpcId": {
387-
"Ref": "MyVpcF9F0CA6F"
388-
},
389386
"InternetGatewayId": {
390387
"Ref": "MyVpcIGW5C4A4F63"
388+
},
389+
"VpcId": {
390+
"Ref": "MyVpcF9F0CA6F"
391391
}
392392
}
393393
},
394394
"myNACL198AF6597": {
395395
"Type": "AWS::EC2::NetworkAcl",
396396
"Properties": {
397+
"Tags": [
398+
{
399+
"Key": "Name",
400+
"Value": "CustomNetworkAclName"
401+
}
402+
],
397403
"VpcId": {
398404
"Ref": "MyVpcF9F0CA6F"
399405
}
@@ -424,35 +430,35 @@
424430
"myNACL1AllowDNSEgressD49F54D3": {
425431
"Type": "AWS::EC2::NetworkAclEntry",
426432
"Properties": {
433+
"CidrBlock": "172.16.0.0/24",
434+
"Egress": true,
427435
"NetworkAclId": {
428436
"Ref": "myNACL198AF6597"
429437
},
430-
"Protocol": 17,
431-
"RuleAction": "allow",
432-
"RuleNumber": 100,
433-
"CidrBlock": "172.16.0.0/24",
434-
"Egress": true,
435438
"PortRange": {
436439
"From": 53,
437440
"To": 53
438-
}
441+
},
442+
"Protocol": 17,
443+
"RuleAction": "allow",
444+
"RuleNumber": 100
439445
}
440446
},
441447
"myNACL1AllowDNSIngress3030B2C3": {
442448
"Type": "AWS::EC2::NetworkAclEntry",
443449
"Properties": {
450+
"CidrBlock": "0.0.0.0/0",
451+
"Egress": false,
444452
"NetworkAclId": {
445453
"Ref": "myNACL198AF6597"
446454
},
447-
"Protocol": 17,
448-
"RuleAction": "allow",
449-
"RuleNumber": 100,
450-
"CidrBlock": "0.0.0.0/0",
451-
"Egress": false,
452455
"PortRange": {
453456
"From": 53,
454457
"To": 53
455-
}
458+
},
459+
"Protocol": 17,
460+
"RuleAction": "allow",
461+
"RuleNumber": 100
456462
}
457463
}
458464
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"21.0.0"}
1+
{"version":"34.0.0"}

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-networkacl.js.snapshot/integ.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "34.0.0",
33
"testCases": {
44
"integ.vpc-networkacl": {
55
"stacks": [

0 commit comments

Comments
 (0)