Skip to content

Commit 9ccb8fc

Browse files
Terraform Team AutomationNishtha Goel
authored andcommitted
Added - Support for OCI NLB Proxy Protocol Support
1 parent 4ec48f8 commit 9ccb8fc

File tree

8 files changed

+49
-4
lines changed

8 files changed

+49
-4
lines changed

examples/network_load_balancer/network_load_balancer_full/nlb_full.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,16 @@ resource "oci_network_load_balancer_backend_set" "nlb-bes2" {
380380
interval_in_millis = 10000
381381
retries = 3
382382
}
383-
depends_on = [oci_network_load_balancer_backend_set.nlb-bes1]
383+
384+
depends_on = [oci_network_load_balancer_backend_set.nlb-bes1]
384385
}
385386

386387
resource "oci_network_load_balancer_backend_set" "nlb-bes3" {
387388
name = "nlb-bes3"
388389
network_load_balancer_id = oci_network_load_balancer_network_load_balancer.nlb1.id
389390
policy = "THREE_TUPLE"
390391
is_fail_open = false
391-
is_instant_failover_enabled = false
392+
is_instant_failover_enabled = true
392393

393394

394395
health_checker {
@@ -414,6 +415,7 @@ resource "oci_network_load_balancer_listener" "nlb-listener1" {
414415
default_backend_set_name = oci_network_load_balancer_backend_set.nlb-bes1.name
415416
port = 80
416417
protocol = "TCP"
418+
is_ppv2enabled = true
417419
depends_on = [oci_network_load_balancer_backend_set.nlb-bes3]
418420
}
419421

internal/integrationtest/network_load_balancer_listener_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var (
4444
"name": acctest.Representation{RepType: acctest.Required, Create: `example_listener`},
4545
"network_load_balancer_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}`},
4646
"port": acctest.Representation{RepType: acctest.Required, Create: `10`, Update: `11`},
47+
"is_ppv2enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
4748
"protocol": acctest.Representation{RepType: acctest.Required, Create: `UDP`, Update: `TCP`},
4849
"ip_version": acctest.Representation{RepType: acctest.Optional, Create: `IPV4`},
4950
}
@@ -103,6 +104,7 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
103104
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
104105
resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"),
105106
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"),
107+
resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "false"),
106108
resource.TestCheckResourceAttr(resourceName, "name", "example_listener"),
107109
resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"),
108110
resource.TestCheckResourceAttr(resourceName, "port", "10"),
@@ -125,6 +127,7 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
125127
acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_listener", "test_listener", acctest.Optional, acctest.Update, NetworkLoadBalancerListenerRepresentation),
126128
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
127129
resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"),
130+
resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "true"),
128131
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"),
129132
resource.TestCheckResourceAttr(resourceName, "name", "example_listener"),
130133
resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"),
@@ -160,6 +163,7 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
160163
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
161164
resource.TestCheckResourceAttrSet(singularDatasourceName, "listener_name"),
162165
resource.TestCheckResourceAttrSet(singularDatasourceName, "network_load_balancer_id"),
166+
resource.TestCheckResourceAttr(singularDatasourceName, "is_ppv2enabled", "true"),
163167
resource.TestCheckResourceAttr(singularDatasourceName, "ip_version", "IPV4"),
164168
resource.TestCheckResourceAttr(singularDatasourceName, "name", "example_listener"),
165169
resource.TestCheckResourceAttr(singularDatasourceName, "port", "11"),

internal/service/network_load_balancer/network_load_balancer_listener_data_source.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ func (s *NetworkLoadBalancerListenerDataSourceCrud) SetData() error {
7979
s.D.Set("default_backend_set_name", *s.Res.DefaultBackendSetName)
8080
}
8181
s.D.Set("ip_version", s.Res.IpVersion)
82+
83+
if s.Res.IsPpv2Enabled != nil {
84+
s.D.Set("is_ppv2enabled", *s.Res.IsPpv2Enabled)
85+
}
86+
8287
if s.Res.Name != nil {
8388
s.D.Set("name", *s.Res.Name)
8489
}

internal/service/network_load_balancer/network_load_balancer_listener_resource.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ func NetworkLoadBalancerListenerResource() *schema.Resource {
6363
Optional: true,
6464
Computed: true,
6565
},
66+
67+
"is_ppv2enabled": {
68+
Type: schema.TypeBool,
69+
Optional: true,
70+
Computed: true,
71+
},
72+
6673
// Computed
6774
},
6875
}
@@ -122,6 +129,12 @@ func (s *NetworkLoadBalancerListenerResourceCrud) Create() error {
122129
if ipVersion, ok := s.D.GetOkExists("ip_version"); ok {
123130
request.IpVersion = oci_network_load_balancer.IpVersionEnum(ipVersion.(string))
124131
}
132+
133+
if isPpv2Enabled, ok := s.D.GetOkExists("is_ppv2enabled"); ok {
134+
tmp := isPpv2Enabled.(bool)
135+
request.IsPpv2Enabled = &tmp
136+
}
137+
125138
if name, ok := s.D.GetOkExists("name"); ok {
126139
tmp := name.(string)
127140
request.Name = &tmp
@@ -312,6 +325,12 @@ func (s *NetworkLoadBalancerListenerResourceCrud) Update() error {
312325
if ipVersion, ok := s.D.GetOkExists("ip_version"); ok {
313326
request.IpVersion = oci_network_load_balancer.IpVersionEnum(ipVersion.(string))
314327
}
328+
329+
if isPpv2Enabled, ok := s.D.GetOkExists("is_ppv2enabled"); ok {
330+
tmp := isPpv2Enabled.(bool)
331+
request.IsPpv2Enabled = &tmp
332+
}
333+
315334
if listenerName, ok := s.D.GetOkExists("name"); ok {
316335
tmp := listenerName.(string)
317336
request.ListenerName = &tmp
@@ -383,6 +402,11 @@ func (s *NetworkLoadBalancerListenerResourceCrud) SetData() error {
383402
s.D.Set("default_backend_set_name", *s.Res.DefaultBackendSetName)
384403
}
385404
s.D.Set("ip_version", s.Res.IpVersion)
405+
406+
if s.Res.IsPpv2Enabled != nil {
407+
s.D.Set("is_ppv2enabled", *s.Res.IsPpv2Enabled)
408+
}
409+
386410
if s.Res.Name != nil {
387411
s.D.Set("name", *s.Res.Name)
388412
}
@@ -423,6 +447,11 @@ func NlbListenerSummaryToMap(obj oci_network_load_balancer.ListenerSummary) map[
423447
result["default_backend_set_name"] = string(*obj.DefaultBackendSetName)
424448
}
425449
result["ip_version"] = string(obj.IpVersion)
450+
451+
if obj.IsPpv2Enabled != nil {
452+
result["is_ppv2enabled"] = bool(*obj.IsPpv2Enabled)
453+
}
454+
426455
if obj.Name != nil {
427456
result["name"] = string(*obj.Name)
428457
}

website/docs/d/network_load_balancer_listener.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ The following arguments are supported:
3535
The following attributes are exported:
3636

3737
* `default_backend_set_name` - The name of the associated backend set. Example: `example_backend_set`
38-
* `ip_version` - IP version associated with the listener.
38+
* `ip_version` - IP version associated with the listener.
39+
* `is_ppv2enabled` - Property to enable/disable PPv2 feature for this listener.
3940
* `name` - A friendly name for the listener. It must be unique and it cannot be changed. Example: `example_listener`
4041
* `port` - The communication port for the listener. Example: `80`
4142
* `protocol` - The protocol on which the listener accepts connection requests. For public network load balancers, ANY protocol refers to TCP/UDP with the wildcard port. For private network load balancers, ANY protocol refers to TCP/UDP/ICMP (note that ICMP requires isPreserveSourceDestination to be set to true). "ListNetworkLoadBalancersProtocols" API is deprecated and it will not return the updated values. Use the allowed values for the protocol instead. Example: `TCP`

website/docs/d/network_load_balancer_listeners.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following attributes are exported:
4040

4141
* `default_backend_set_name` - The name of the associated backend set. Example: `example_backend_set`
4242
* `ip_version` - IP version associated with the listener.
43+
* `is_ppv2enabled` - Property to enable/disable PPv2 feature for this listener.
4344
* `name` - A friendly name for the listener. It must be unique and it cannot be changed. Example: `example_listener`
4445
* `port` - The communication port for the listener. Example: `80`
4546
* `protocol` - The protocol on which the listener accepts connection requests. For public network load balancers, ANY protocol refers to TCP/UDP with the wildcard port. For private network load balancers, ANY protocol refers to TCP/UDP/ICMP (note that ICMP requires isPreserveSourceDestination to be set to true). "ListNetworkLoadBalancersProtocols" API is deprecated and it will not return the updated values. Use the allowed values for the protocol instead. Example: `TCP`

website/docs/r/network_load_balancer_backend_set.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The following arguments are supported:
6666
* `name` - (Optional) (Updatable) A read-only field showing the IP address/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`
6767
* `port` - (Required) (Updatable) The communication port for the backend server. Example: `8080`
6868
* `target_id` - (Optional) (Updatable) The IP OCID/Instance OCID associated with the backend server. Example: `ocid1.privateip..oc1.<var>&lt;unique_ID&gt;</var>`
69-
* `weight` - (Optional) (Updatable) 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`
69+
* `weight` - (Optional) (Updatable) 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`
7070
* `health_checker` - (Required) (Updatable) The health check policy configuration. For more information, see [Editing Health Check Policies](https://docs.cloud.oracle.com/iaas/Content/Balance/Tasks/editinghealthcheck.htm).
7171
* `dns` - (Optional) (Updatable) DNS healthcheck configurations.
7272
* `domain_name` - (Required) (Updatable) 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.

website/docs/r/network_load_balancer_listener.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "oci_network_load_balancer_listener" "test_listener" {
2525
2626
#Optional
2727
ip_version = var.listener_ip_version
28+
is_ppv2enabled = var.listener_is_ppv2enabled
2829
}
2930
```
3031

@@ -34,6 +35,7 @@ The following arguments are supported:
3435

3536
* `default_backend_set_name` - (Required) (Updatable) The name of the associated backend set. Example: `example_backend_set`
3637
* `ip_version` - (Optional) (Updatable) IP version associated with the listener.
38+
* `is_ppv2enabled` - (Optional) (Updatable) Property to enable/disable PPv2 feature for this listener.
3739
* `name` - (Required) A friendly name for the listener. It must be unique and it cannot be changed. Example: `example_listener`
3840
* `network_load_balancer_id` - (Required) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the network load balancer to update.
3941
* `port` - (Required) (Updatable) The communication port for the listener. Example: `80`
@@ -49,6 +51,7 @@ The following attributes are exported:
4951

5052
* `default_backend_set_name` - The name of the associated backend set. Example: `example_backend_set`
5153
* `ip_version` - IP version associated with the listener.
54+
* `is_ppv2enabled` - Property to enable/disable PPv2 feature for this listener.
5255
* `name` - A friendly name for the listener. It must be unique and it cannot be changed. Example: `example_listener`
5356
* `port` - The communication port for the listener. Example: `80`
5457
* `protocol` - The protocol on which the listener accepts connection requests. For public network load balancers, ANY protocol refers to TCP/UDP with the wildcard port. For private network load balancers, ANY protocol refers to TCP/UDP/ICMP (note that ICMP requires isPreserveSourceDestination to be set to true). "ListNetworkLoadBalancersProtocols" API is deprecated and it will not return the updated values. Use the allowed values for the protocol instead. Example: `TCP`

0 commit comments

Comments
 (0)