Skip to content

Commit e03a41f

Browse files
authored
feat(elasticloadbalancingv2): dualstack NetworkLoadBalancer (#27546)
Adds support for dual-stack NetworkLoadBalancer via the [`ipAddressType`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html#cfn-elasticloadbalancingv2-loadbalancer-ipaddresstype) property. Example: ``` const lb = new elbv2.NetworkLoadBalancer(this, 'LB', { vpc, internetFacing: true ipAddressType: elbv2.IpAddressType.DUAL_STACK, }); ``` Also, added validation to enforce that UDP or TCP_UDP listeners cannot be added to a dualstack NLB. Closes #27538. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 00331a7 commit e03a41f

25 files changed

+3338
-6
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-elasticloadbalancingv2/test/integ.alb.dualstack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const ipv6Block = new ec2.CfnVPCCidrBlock(
4141
// public subnets.
4242
const internetGateway = valueOrDie<IConstruct, ec2.CfnInternetGateway>(
4343
vpc.node.children.find(c => c instanceof ec2.CfnInternetGateway),
44-
new Error('Couldnt find an internet gateway'),
44+
new Error('Couldn\'t find an internet gateway'),
4545
);
4646

4747
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', {

packages/@aws-cdk-testing/framework-integ/test/aws-elasticloadbalancingv2/test/integ.nlb.dualstack.internal.js.snapshot/NlbDualstackInternalIntegDefaultTestDeployAssertEEBE69CB.assets.json

+19
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-elasticloadbalancingv2/test/integ.nlb.dualstack.internal.js.snapshot/NlbDualstackInternalIntegDefaultTestDeployAssertEEBE69CB.template.json

+36
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-elasticloadbalancingv2/test/integ.nlb.dualstack.internal.js.snapshot/aws-cdk-nlb-dualstack-internal.assets.json

+19
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,303 @@
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-nlb-dualstack-internal/VPC"
14+
}
15+
]
16+
}
17+
},
18+
"VPCIsolatedSubnet1SubnetEBD00FC6": {
19+
"Type": "AWS::EC2::Subnet",
20+
"Properties": {
21+
"AssignIpv6AddressOnCreation": true,
22+
"AvailabilityZone": {
23+
"Fn::Select": [
24+
0,
25+
{
26+
"Fn::GetAZs": ""
27+
}
28+
]
29+
},
30+
"CidrBlock": "10.0.0.0/17",
31+
"Ipv6CidrBlock": {
32+
"Fn::Select": [
33+
0,
34+
{
35+
"Fn::Cidr": [
36+
{
37+
"Fn::Select": [
38+
0,
39+
{
40+
"Fn::GetAtt": [
41+
"VPCB9E5F0B4",
42+
"Ipv6CidrBlocks"
43+
]
44+
}
45+
]
46+
},
47+
256,
48+
"64"
49+
]
50+
}
51+
]
52+
},
53+
"MapPublicIpOnLaunch": false,
54+
"Tags": [
55+
{
56+
"Key": "aws-cdk:subnet-name",
57+
"Value": "Isolated"
58+
},
59+
{
60+
"Key": "aws-cdk:subnet-type",
61+
"Value": "Isolated"
62+
},
63+
{
64+
"Key": "Name",
65+
"Value": "aws-cdk-nlb-dualstack-internal/VPC/IsolatedSubnet1"
66+
}
67+
],
68+
"VpcId": {
69+
"Ref": "VPCB9E5F0B4"
70+
}
71+
},
72+
"DependsOn": [
73+
"IPv6Block"
74+
]
75+
},
76+
"VPCIsolatedSubnet1RouteTableEB156210": {
77+
"Type": "AWS::EC2::RouteTable",
78+
"Properties": {
79+
"Tags": [
80+
{
81+
"Key": "Name",
82+
"Value": "aws-cdk-nlb-dualstack-internal/VPC/IsolatedSubnet1"
83+
}
84+
],
85+
"VpcId": {
86+
"Ref": "VPCB9E5F0B4"
87+
}
88+
},
89+
"DependsOn": [
90+
"IPv6Block"
91+
]
92+
},
93+
"VPCIsolatedSubnet1RouteTableAssociationA2D18F7C": {
94+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
95+
"Properties": {
96+
"RouteTableId": {
97+
"Ref": "VPCIsolatedSubnet1RouteTableEB156210"
98+
},
99+
"SubnetId": {
100+
"Ref": "VPCIsolatedSubnet1SubnetEBD00FC6"
101+
}
102+
},
103+
"DependsOn": [
104+
"IPv6Block"
105+
]
106+
},
107+
"VPCIsolatedSubnet2Subnet4B1C8CAA": {
108+
"Type": "AWS::EC2::Subnet",
109+
"Properties": {
110+
"AssignIpv6AddressOnCreation": true,
111+
"AvailabilityZone": {
112+
"Fn::Select": [
113+
1,
114+
{
115+
"Fn::GetAZs": ""
116+
}
117+
]
118+
},
119+
"CidrBlock": "10.0.128.0/17",
120+
"Ipv6CidrBlock": {
121+
"Fn::Select": [
122+
1,
123+
{
124+
"Fn::Cidr": [
125+
{
126+
"Fn::Select": [
127+
0,
128+
{
129+
"Fn::GetAtt": [
130+
"VPCB9E5F0B4",
131+
"Ipv6CidrBlocks"
132+
]
133+
}
134+
]
135+
},
136+
256,
137+
"64"
138+
]
139+
}
140+
]
141+
},
142+
"MapPublicIpOnLaunch": false,
143+
"Tags": [
144+
{
145+
"Key": "aws-cdk:subnet-name",
146+
"Value": "Isolated"
147+
},
148+
{
149+
"Key": "aws-cdk:subnet-type",
150+
"Value": "Isolated"
151+
},
152+
{
153+
"Key": "Name",
154+
"Value": "aws-cdk-nlb-dualstack-internal/VPC/IsolatedSubnet2"
155+
}
156+
],
157+
"VpcId": {
158+
"Ref": "VPCB9E5F0B4"
159+
}
160+
},
161+
"DependsOn": [
162+
"IPv6Block"
163+
]
164+
},
165+
"VPCIsolatedSubnet2RouteTable9B4F78DC": {
166+
"Type": "AWS::EC2::RouteTable",
167+
"Properties": {
168+
"Tags": [
169+
{
170+
"Key": "Name",
171+
"Value": "aws-cdk-nlb-dualstack-internal/VPC/IsolatedSubnet2"
172+
}
173+
],
174+
"VpcId": {
175+
"Ref": "VPCB9E5F0B4"
176+
}
177+
},
178+
"DependsOn": [
179+
"IPv6Block"
180+
]
181+
},
182+
"VPCIsolatedSubnet2RouteTableAssociation7BF8E0EB": {
183+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
184+
"Properties": {
185+
"RouteTableId": {
186+
"Ref": "VPCIsolatedSubnet2RouteTable9B4F78DC"
187+
},
188+
"SubnetId": {
189+
"Ref": "VPCIsolatedSubnet2Subnet4B1C8CAA"
190+
}
191+
},
192+
"DependsOn": [
193+
"IPv6Block"
194+
]
195+
},
196+
"IPv6Block": {
197+
"Type": "AWS::EC2::VPCCidrBlock",
198+
"Properties": {
199+
"AmazonProvidedIpv6CidrBlock": true,
200+
"VpcId": {
201+
"Ref": "VPCB9E5F0B4"
202+
}
203+
}
204+
},
205+
"LB8A12904C": {
206+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
207+
"Properties": {
208+
"IpAddressType": "dualstack",
209+
"LoadBalancerAttributes": [
210+
{
211+
"Key": "deletion_protection.enabled",
212+
"Value": "false"
213+
}
214+
],
215+
"Scheme": "internal",
216+
"Subnets": [
217+
{
218+
"Ref": "VPCIsolatedSubnet1SubnetEBD00FC6"
219+
},
220+
{
221+
"Ref": "VPCIsolatedSubnet2Subnet4B1C8CAA"
222+
}
223+
],
224+
"Type": "network"
225+
}
226+
},
227+
"LBListener49E825B4": {
228+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
229+
"Properties": {
230+
"DefaultActions": [
231+
{
232+
"TargetGroupArn": {
233+
"Ref": "tg2DCFFD86"
234+
},
235+
"Type": "forward"
236+
}
237+
],
238+
"LoadBalancerArn": {
239+
"Ref": "LB8A12904C"
240+
},
241+
"Port": 3000,
242+
"Protocol": "TCP"
243+
}
244+
},
245+
"tg2DCFFD86": {
246+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
247+
"Properties": {
248+
"HealthCheckIntervalSeconds": 250,
249+
"HealthCheckProtocol": "TCP",
250+
"HealthCheckTimeoutSeconds": 100,
251+
"HealthyThresholdCount": 5,
252+
"Port": 3000,
253+
"Protocol": "TCP",
254+
"UnhealthyThresholdCount": 2,
255+
"VpcId": {
256+
"Ref": "VPCB9E5F0B4"
257+
}
258+
},
259+
"DependsOn": [
260+
"VPCIsolatedSubnet1RouteTableEB156210",
261+
"VPCIsolatedSubnet1RouteTableAssociationA2D18F7C",
262+
"VPCIsolatedSubnet1SubnetEBD00FC6",
263+
"VPCIsolatedSubnet2RouteTable9B4F78DC",
264+
"VPCIsolatedSubnet2RouteTableAssociation7BF8E0EB",
265+
"VPCIsolatedSubnet2Subnet4B1C8CAA"
266+
]
267+
}
268+
},
269+
"Parameters": {
270+
"BootstrapVersion": {
271+
"Type": "AWS::SSM::Parameter::Value<String>",
272+
"Default": "/cdk-bootstrap/hnb659fds/version",
273+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
274+
}
275+
},
276+
"Rules": {
277+
"CheckBootstrapVersion": {
278+
"Assertions": [
279+
{
280+
"Assert": {
281+
"Fn::Not": [
282+
{
283+
"Fn::Contains": [
284+
[
285+
"1",
286+
"2",
287+
"3",
288+
"4",
289+
"5"
290+
],
291+
{
292+
"Ref": "BootstrapVersion"
293+
}
294+
]
295+
}
296+
]
297+
},
298+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
299+
}
300+
]
301+
}
302+
}
303+
}

packages/@aws-cdk-testing/framework-integ/test/aws-elasticloadbalancingv2/test/integ.nlb.dualstack.internal.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)