Skip to content

Commit a4aa28e

Browse files
Added - Support for ESP & ICMP traffic support in NLB
1 parent 344972b commit a4aa28e

14 files changed

+185
-43
lines changed

examples/network_load_balancer/network_load_balancer_full/nlb_full.tf

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,32 @@ resource "oci_network_load_balancer_backend_set" "nlb-bes3" {
409409
depends_on = [oci_network_load_balancer_backend_set.nlb-bes2]
410410
}
411411

412+
resource "oci_network_load_balancer_backend_set" "nlb-bes4" {
413+
name = "nlb-bes4"
414+
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb1.id
415+
policy = "THREE_TUPLE"
416+
is_fail_open = false
417+
is_instant_failover_enabled = true
418+
is_preserve_source = true
419+
420+
health_checker {
421+
port = "53"
422+
protocol = "DNS"
423+
timeout_in_millis = 10000
424+
interval_in_millis = 10000
425+
retries = 3
426+
dns {
427+
domain_name = "oracle.com"
428+
query_class = "IN"
429+
query_type = "A"
430+
rcodes = ["NOERROR", "SERVFAIL"]
431+
transport_protocol = "UDP"
432+
}
433+
}
434+
depends_on = [oci_network_load_balancer_backend_set.nlb-bes3]
435+
}
436+
437+
412438
resource "oci_network_load_balancer_listener" "nlb-listener1" {
413439
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb1.id
414440
name = "tcp_listener"
@@ -417,7 +443,7 @@ resource "oci_network_load_balancer_listener" "nlb-listener1" {
417443
protocol = "TCP"
418444
tcp_idle_timeout = 360
419445
is_ppv2enabled = true
420-
depends_on = [oci_network_load_balancer_backend_set.nlb-bes3]
446+
depends_on = [oci_network_load_balancer_backend_set.nlb-bes4]
421447
}
422448

423449
resource "oci_network_load_balancer_listener" "nlb-listener2" {
@@ -441,6 +467,18 @@ resource "oci_network_load_balancer_listener" "nlb-listener3" {
441467
depends_on = [oci_network_load_balancer_listener.nlb-listener2]
442468
}
443469

470+
resource "oci_network_load_balancer_listener" "nlb-listener4" {
471+
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb1.id
472+
name = "l3_ip_listener"
473+
default_backend_set_name = oci_network_load_balancer_backend_set.nlb-bes4.name
474+
port = 0
475+
protocol = "L3IP"
476+
tcp_idle_timeout = 240
477+
udp_idle_timeout = 180
478+
l3ip_idle_timeout = 360
479+
depends_on = [oci_network_load_balancer_listener.nlb-listener3]
480+
}
481+
444482
resource "oci_network_load_balancer_backend" "nlb-be1" {
445483
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb1.id
446484
backend_set_name = oci_network_load_balancer_backend_set.nlb-bes1.name
@@ -450,7 +488,7 @@ resource "oci_network_load_balancer_backend" "nlb-be1" {
450488
is_drain = false
451489
is_offline = false
452490
weight = 1
453-
depends_on = [oci_network_load_balancer_listener.nlb-listener3]
491+
depends_on = [oci_network_load_balancer_listener.nlb-listener4]
454492
}
455493

456494
resource "oci_network_load_balancer_backend" "nlb-be2" {

internal/integrationtest/network_load_balancer_listener_test.go

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,26 @@ var (
7474
"ip_version": acctest.Representation{RepType: acctest.Optional, Create: `IPV4`},
7575
}
7676

77+
NetworkLoadBalancerL3IPListenerRepresentation = map[string]interface{}{
78+
"default_backend_set_name": acctest.Representation{RepType: acctest.Required, Create: `${oci_network_load_balancer_backend_set.test_backend_set.name}`},
79+
"name": acctest.Representation{RepType: acctest.Required, Create: `example_listener`},
80+
"network_load_balancer_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}`},
81+
"port": acctest.Representation{RepType: acctest.Required, Create: `0`, Update: `0`},
82+
"tcp_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `180`, Update: `240`},
83+
"udp_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `180`, Update: `300`},
84+
"l3ip_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `200`, Update: `400`},
85+
"protocol": acctest.Representation{RepType: acctest.Required, Create: `L3IP`},
86+
"ip_version": acctest.Representation{RepType: acctest.Optional, Create: `IPV4`},
87+
"is_ppv2enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
88+
}
89+
7790
NetworkLoadBalancerListenerResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
7891
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation) +
79-
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_backend_set", "test_backend_set", acctest.Required, acctest.Create, NetworkLoadBalancerBackendSetRepresentation) +
92+
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_backend_set", "test_backend_set", acctest.Required, acctest.Create,
93+
acctest.RepresentationCopyWithNewProperties(NetworkLoadBalancerBackendSetRepresentation, map[string]interface{}{
94+
"is_preserve_source": acctest.Representation{RepType: acctest.Optional, Create: `true`},
95+
"policy": acctest.Representation{RepType: acctest.Required, Create: `TWO_TUPLE`, Update: `THREE_TUPLE`},
96+
})) +
8097
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_network_load_balancer", "test_network_load_balancer", acctest.Required, acctest.Create, NetworkLoadBalancerNetworkLoadBalancerRepresentation)
8198
)
8299

@@ -199,7 +216,6 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
199216
},
200217
),
201218
},
202-
203219
// verify updates to updatable parameters
204220
{
205221
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
@@ -228,6 +244,62 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
228244
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies,
229245
},
230246

247+
// verify L3IP Listener create with optionals
248+
{
249+
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
250+
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_listener", "test_listener", acctest.Optional, acctest.Create, NetworkLoadBalancerL3IPListenerRepresentation),
251+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
252+
resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"),
253+
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"),
254+
resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "false"),
255+
resource.TestCheckResourceAttr(resourceName, "name", "example_listener"),
256+
resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"),
257+
resource.TestCheckResourceAttr(resourceName, "port", "0"),
258+
resource.TestCheckResourceAttr(resourceName, "protocol", "L3IP"),
259+
resource.TestCheckResourceAttr(resourceName, "tcp_idle_timeout", "180"),
260+
resource.TestCheckResourceAttr(resourceName, "udp_idle_timeout", "180"),
261+
resource.TestCheckResourceAttr(resourceName, "l3ip_idle_timeout", "200"),
262+
263+
func(s *terraform.State) (err error) {
264+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
265+
if isEnableExportCompartment, _ := strconv.ParseBool(utils.GetEnvSettingWithDefault("enable_export_compartment", "true")); isEnableExportCompartment {
266+
if errExport := resourcediscovery.TestExportCompartmentWithResourceName(&resId, &compartmentId, resourceName); errExport != nil {
267+
return errExport
268+
}
269+
}
270+
return err
271+
},
272+
),
273+
},
274+
// verify L3IP updates to updatable parameters
275+
{
276+
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
277+
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_listener", "test_listener", acctest.Optional, acctest.Update, NetworkLoadBalancerL3IPListenerRepresentation),
278+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
279+
resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"),
280+
resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "true"),
281+
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"),
282+
resource.TestCheckResourceAttr(resourceName, "name", "example_listener"),
283+
resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"),
284+
resource.TestCheckResourceAttr(resourceName, "port", "0"),
285+
resource.TestCheckResourceAttr(resourceName, "protocol", "L3IP"),
286+
resource.TestCheckResourceAttr(resourceName, "tcp_idle_timeout", "240"),
287+
resource.TestCheckResourceAttr(resourceName, "udp_idle_timeout", "300"),
288+
resource.TestCheckResourceAttr(resourceName, "l3ip_idle_timeout", "400"),
289+
func(s *terraform.State) (err error) {
290+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
291+
if resId != resId2 {
292+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
293+
}
294+
return err
295+
},
296+
),
297+
},
298+
// delete before next Create
299+
{
300+
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies,
301+
},
302+
231303
// verify Create with optionals
232304
{
233305
Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +

internal/integrationtest/network_load_balancer_network_load_balancer_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,18 @@ func TestNetworkLoadBalancerNetworkLoadBalancerResource_basic(t *testing.T) {
156156
var resId, resId2 string
157157

158158
acctest.ResourceTest(t, testAccCheckNetworkLoadBalancerNetworkLoadBalancerDestroy, []resource.TestStep{
159+
// Initialize Tag dependencies: After a tag is created, if it is defined in the resource immediately, a 400-InvalidParameter error due to invalid tags may be returned.
160+
// However, this error is not observed if we wait for some time. To prevent the issue, a preconfigured 30-second wait is added.
161+
{
162+
Config: config + compartmentIdVariableStr + DefinedTagsDependencies,
163+
},
164+
159165
// verify Create with optionals
160166
{
167+
//wait for 30 sec
168+
PreConfig: func() {
169+
time.Sleep(30 * time.Second)
170+
},
161171
Config: config + compartmentIdVariableStr + NetworkLoadBalancerNetworkLoadBalancerResourceDependencies + NetworkLoadBalancerReservedIpDependencies +
162172
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_network_load_balancer", "test_network_load_balancer", acctest.Optional, acctest.Create, networkLoadBalancerRepresentationIpv6),
163173
Check: acctest.ComposeAggregateTestCheckFuncWrapper(

internal/service/network_load_balancer/network_load_balancer_listener_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ func (s *NetworkLoadBalancerListenerDataSourceCrud) SetData() error {
8484
s.D.Set("is_ppv2enabled", *s.Res.IsPpv2Enabled)
8585
}
8686

87+
if s.Res.L3IpIdleTimeout != nil {
88+
s.D.Set("l3ip_idle_timeout", *s.Res.L3IpIdleTimeout)
89+
}
90+
8791
if s.Res.Name != nil {
8892
s.D.Set("name", *s.Res.Name)
8993
}

internal/service/network_load_balancer/network_load_balancer_listener_resource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func NetworkLoadBalancerListenerResource() *schema.Resource {
6969
Optional: true,
7070
Computed: true,
7171
},
72+
"l3ip_idle_timeout": {
73+
Type: schema.TypeInt,
74+
Optional: true,
75+
Computed: true,
76+
},
7277
"tcp_idle_timeout": {
7378
Type: schema.TypeInt,
7479
Optional: true,
@@ -145,6 +150,11 @@ func (s *NetworkLoadBalancerListenerResourceCrud) Create() error {
145150
request.IsPpv2Enabled = &tmp
146151
}
147152

153+
if l3IpIdleTimeout, ok := s.D.GetOkExists("l3ip_idle_timeout"); ok {
154+
tmp := l3IpIdleTimeout.(int)
155+
request.L3IpIdleTimeout = &tmp
156+
}
157+
148158
if name, ok := s.D.GetOkExists("name"); ok {
149159
tmp := name.(string)
150160
request.Name = &tmp
@@ -351,6 +361,11 @@ func (s *NetworkLoadBalancerListenerResourceCrud) Update() error {
351361
request.IsPpv2Enabled = &tmp
352362
}
353363

364+
if l3IpIdleTimeout, ok := s.D.GetOkExists("l3ip_idle_timeout"); ok {
365+
tmp := l3IpIdleTimeout.(int)
366+
request.L3IpIdleTimeout = &tmp
367+
}
368+
354369
if listenerName, ok := s.D.GetOkExists("name"); ok {
355370
tmp := listenerName.(string)
356371
request.ListenerName = &tmp
@@ -437,6 +452,10 @@ func (s *NetworkLoadBalancerListenerResourceCrud) SetData() error {
437452
s.D.Set("is_ppv2enabled", *s.Res.IsPpv2Enabled)
438453
}
439454

455+
if s.Res.L3IpIdleTimeout != nil {
456+
s.D.Set("l3ip_idle_timeout", *s.Res.L3IpIdleTimeout)
457+
}
458+
440459
if s.Res.Name != nil {
441460
s.D.Set("name", *s.Res.Name)
442461
}
@@ -490,6 +509,10 @@ func NlbListenerSummaryToMap(obj oci_network_load_balancer.ListenerSummary) map[
490509
result["is_ppv2enabled"] = bool(*obj.IsPpv2Enabled)
491510
}
492511

512+
if obj.L3IpIdleTimeout != nil {
513+
result["l3ip_idle_timeout"] = int(*obj.L3IpIdleTimeout)
514+
}
515+
493516
if obj.Name != nil {
494517
result["name"] = string(*obj.Name)
495518
}

website/docs/d/network_load_balancer_backend_set.html.markdown

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ The following arguments are supported:
3636

3737
The following attributes are exported:
3838

39-
* `backends` - Array of backends.
40-
* `ip_address` - The IP address of the backend server. Example: `10.0.0.3`
41-
* `is_backup` - Whether the network load balancer should treat this server as a backup unit. If `true`, then the network load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "isBackup" fail the health check policy. Example: `false`
42-
* `is_drain` - Whether the network load balancer should drain this server. Servers marked "isDrain" receive no incoming traffic. Example: `false`
43-
* `is_offline` - Whether the network load balancer should treat this server as offline. Offline servers receive no incoming traffic. Example: `false`
44-
* `name` - A read-only field showing the IP address/IP OCID and port that uniquely identify this backend server in the backend set. Example: `10.0.0.3:8080`, or `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>:443` or `10.0.0.3:0`
45-
* `port` - The communication port for the backend server. Example: `8080`
46-
* `target_id` - The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`
47-
* `weight` - The network load balancing policy weight assigned to the server. Backend servers with a higher weight receive a larger proportion of incoming traffic. For example, a server weighted '3' receives three times the number of new connections as a server weighted '1'. For more information about load balancing policies, see [How Network Load Balancing Policies Work](https://docs.cloud.oracle.com/iaas/Content/Balance/Reference/lbpolicies.htm). Example: `3`
48-
* `health_checker` - The health check policy configuration. For more information, see [Editing Health Check Policies](https://docs.cloud.oracle.com/iaas/Content/Balance/Tasks/editinghealthcheck.htm).
39+
* `backends` - An array of backends.
40+
* `ip_address` - The IP address of the backend server. Example: `10.0.0.3`
41+
* `is_backup` - Whether the network load balancer should treat this server as a backup unit. If `true`, then the network load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "isBackup" fail the health check policy. Example: `false`
42+
* `is_drain` - Whether the network load balancer should drain this server. Servers marked "isDrain" receive no incoming traffic. Example: `false`
43+
* `is_offline` - Whether the network load balancer should treat this server as offline. Offline servers receive no incoming traffic. Example: `false`
44+
* `name` - A read-only field showing the IP address/IP OCID and port that uniquely identify this backend server in the backend set. Example: `10.0.0.3:8080`, or `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>:443` or `10.0.0.3:0`
45+
* `port` - The communication port for the backend server. Example: `8080`
46+
* `target_id` - The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`
47+
* `weight` - The network load balancing policy weight assigned to the server. Backend servers with a higher weight receive a larger proportion of incoming traffic. For example, a server weighted '3' receives three times the number of new connections as a server weighted '1'. For more information about load balancing policies, see [How Network Load Balancing Policies Work](https://docs.cloud.oracle.com/iaas/Content/Balance/Reference/lbpolicies.htm). Example: `3`
48+
* `health_checker` - The health check policy configuration. For more information, see [Editing Health Check Policies](https://docs.cloud.oracle.com/iaas/Content/Balance/Tasks/editinghealthcheck.htm).
4949
* `dns` - DNS healthcheck configurations.
5050
* `domain_name` - The absolute fully-qualified domain name to perform periodic DNS queries. If not provided, an extra dot will be added at the end of a domain name during the query.
5151
* `query_class` - The class the dns health check query to use; either IN or CH. Example: `IN`

website/docs/d/network_load_balancer_backend_sets.html.markdown

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ The following attributes are exported:
3838

3939
The following attributes are exported:
4040

41-
* `backends` - Array of backends.
42-
* `ip_address` - The IP address of the backend server. Example: `10.0.0.3`
43-
* `is_backup` - Whether the network load balancer should treat this server as a backup unit. If `true`, then the network load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "isBackup" fail the health check policy. Example: `false`
44-
* `is_drain` - Whether the network load balancer should drain this server. Servers marked "isDrain" receive no incoming traffic. Example: `false`
45-
* `is_offline` - Whether the network load balancer should treat this server as offline. Offline servers receive no incoming traffic. Example: `false`
46-
* `name` - A read-only field showing the IP address/IP OCID and port that uniquely identify this backend server in the backend set. Example: `10.0.0.3:8080`, or `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>:443` or `10.0.0.3:0`
47-
* `port` - The communication port for the backend server. Example: `8080`
48-
* `target_id` - The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`
49-
* `weight` - The network load balancing policy weight assigned to the server. Backend servers with a higher weight receive a larger proportion of incoming traffic. For example, a server weighted '3' receives three times the number of new connections as a server weighted '1'. For more information about load balancing policies, see [How Network Load Balancing Policies Work](https://docs.cloud.oracle.com/iaas/Content/Balance/Reference/lbpolicies.htm). Example: `3`
41+
* `backends` - An array of backends.
42+
* `ip_address` - The IP address of the backend server. Example: `10.0.0.3`
43+
* `is_backup` - Whether the network load balancer should treat this server as a backup unit. If `true`, then the network load balancer forwards no ingress traffic to this backend server unless all other backend servers not marked as "isBackup" fail the health check policy. Example: `false`
44+
* `is_drain` - Whether the network load balancer should drain this server. Servers marked "isDrain" receive no incoming traffic. Example: `false`
45+
* `is_offline` - Whether the network load balancer should treat this server as offline. Offline servers receive no incoming traffic. Example: `false`
46+
* `name` - A read-only field showing the IP address/IP OCID and port that uniquely identify this backend server in the backend set. Example: `10.0.0.3:8080`, or `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>:443` or `10.0.0.3:0`
47+
* `port` - The communication port for the backend server. Example: `8080`
48+
* `target_id` - The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`
49+
* `weight` - The network load balancing policy weight assigned to the server. Backend servers with a higher weight receive a larger proportion of incoming traffic. For example, a server weighted '3' receives three times the number of new connections as a server weighted '1'. For more information about load balancing policies, see [How Network Load Balancing Policies Work](https://docs.cloud.oracle.com/iaas/Content/Balance/Reference/lbpolicies.htm). Example: `3`
5050
* `health_checker` - The health check policy configuration. For more information, see [Editing Health Check Policies](https://docs.cloud.oracle.com/iaas/Content/Balance/Tasks/editinghealthcheck.htm).
5151
* `dns` - DNS healthcheck configurations.
5252
* `domain_name` - The absolute fully-qualified domain name to perform periodic DNS queries. If not provided, an extra dot will be added at the end of a domain name during the query.

0 commit comments

Comments
 (0)