Skip to content

Commit ae0c589

Browse files
Anushree JanaMaxrovr
authored andcommitted
Added - LBCP ppv2 support
1 parent ecd4f5a commit ae0c589

File tree

5 files changed

+55
-6
lines changed

5 files changed

+55
-6
lines changed

examples/load_balancer/lb_full/lb_full.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ variable "availability_domain" {
6565
}
6666

6767
provider "oci" {
68-
// version = "6.9.0" // published on August 27, 2024.
6968
tenancy_ocid = var.tenancy_ocid
7069
user_ocid = var.user_ocid
7170
fingerprint = var.fingerprint
@@ -74,12 +73,12 @@ provider "oci" {
7473
}
7574

7675
data "oci_identity_availability_domain" "ad1" {
77-
compartment_id = var.compartment_ocid // needs to be compartment_ocid if not using root compartment
76+
compartment_id = var.tenancy_ocid // needs to be compartment_ocid if not using root compartment
7877
ad_number = 1
7978
}
8079

8180
data "oci_identity_availability_domain" "ad2" {
82-
compartment_id = var.compartment_ocid // needs to be compartment_ocid if not using root compartment
81+
compartment_id = var.tenancy_ocid // needs to be compartment_ocid if not using root compartment
8382
ad_number = 2
8483
}
8584

@@ -476,7 +475,8 @@ resource "oci_load_balancer_listener" "lb-listener3" {
476475

477476
connection_configuration {
478477
idle_timeout_in_seconds = "2"
479-
backend_tcp_proxy_protocol_version = "1"
478+
backend_tcp_proxy_protocol_version = "2"
479+
backend_tcp_proxy_protocol_options = ["PP2_TYPE_AUTHORITY"]
480480
}
481481
}
482482

internal/integrationtest/load_balancer_listener_tcp_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var (
3030
listenerTcpConnectionConfigurationRepresentation = map[string]interface{}{
3131
"idle_timeout_in_seconds": acctest.Representation{RepType: acctest.Required, Create: `10`, Update: `11`},
3232
"backend_tcp_proxy_protocol_version": acctest.Representation{RepType: acctest.Optional, Create: `1`, Update: `2`},
33+
"backend_tcp_proxy_protocol_options": acctest.Representation{RepType: acctest.Optional, Update: []string{`PP2_TYPE_AUTHORITY`}},
3334
}
3435
)
3536

@@ -60,6 +61,7 @@ func TestLoadBalancerListenerTcpResource_basic(t *testing.T) {
6061
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
6162
resource.TestCheckResourceAttr(resourceName, "connection_configuration.#", "1"),
6263
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.backend_tcp_proxy_protocol_version", "1"),
64+
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.backend_tcp_proxy_protocol_options.#", "0"),
6365
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.idle_timeout_in_seconds", "10"),
6466
resource.TestCheckResourceAttrSet(resourceName, "load_balancer_id"),
6567
resource.TestCheckResourceAttr(resourceName, "name", "mylistener"),
@@ -76,6 +78,8 @@ func TestLoadBalancerListenerTcpResource_basic(t *testing.T) {
7678
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
7779
resource.TestCheckResourceAttr(resourceName, "connection_configuration.#", "1"),
7880
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.backend_tcp_proxy_protocol_version", "2"),
81+
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.backend_tcp_proxy_protocol_options.#", "1"),
82+
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.backend_tcp_proxy_protocol_options.0", "PP2_TYPE_AUTHORITY"),
7983
resource.TestCheckResourceAttr(resourceName, "connection_configuration.0.idle_timeout_in_seconds", "11"),
8084
resource.TestCheckResourceAttrSet(resourceName, "load_balancer_id"),
8185
resource.TestCheckResourceAttr(resourceName, "name", "mylistener"),

internal/service/load_balancer/load_balancer_listener_resource.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ func LoadBalancerListenerResource() *schema.Resource {
7272
DiffSuppressFunc: tfresource.Int64StringDiffSuppressFunction,
7373
},
7474

75+
// Optional
76+
"backend_tcp_proxy_protocol_options": {
77+
Type: schema.TypeList,
78+
Optional: true,
79+
Computed: true,
80+
Elem: &schema.Schema{
81+
Type: schema.TypeString,
82+
},
83+
},
84+
7585
// Optional
7686
"backend_tcp_proxy_protocol_version": {
7787
Type: schema.TypeInt,
@@ -643,9 +653,38 @@ func parseListenerCompositeId(compositeId string) (listenerName string, loadBala
643653
return
644654
}
645655

656+
func toString(s []oci_load_balancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum) []string {
657+
c := make([]string, len(s))
658+
for i, v := range s {
659+
c[i] = string(v)
660+
}
661+
return c
662+
}
663+
664+
func toBackendTcpProxyProtocolOptionsEnum(s []string) []oci_load_balancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum {
665+
c := make([]oci_load_balancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum, len(s))
666+
for i, v := range s {
667+
c[i] = oci_load_balancer.ConnectionConfigurationBackendTcpProxyProtocolOptionsEnum(v)
668+
}
669+
return c
670+
}
671+
646672
func (s *LoadBalancerListenerResourceCrud) mapToConnectionConfiguration(fieldKeyFormat string) (oci_load_balancer.ConnectionConfiguration, error) {
647673
result := oci_load_balancer.ConnectionConfiguration{}
648674

675+
if backendTcpProxyProtocolOptions, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backend_tcp_proxy_protocol_options")); ok {
676+
interfaces := backendTcpProxyProtocolOptions.([]interface{})
677+
tmp := make([]string, len(interfaces))
678+
for i := range interfaces {
679+
if interfaces[i] != nil {
680+
tmp[i] = interfaces[i].(string)
681+
}
682+
}
683+
if len(tmp) != 0 || s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "backend_tcp_proxy_protocol_options")) {
684+
result.BackendTcpProxyProtocolOptions = toBackendTcpProxyProtocolOptionsEnum(tmp)
685+
}
686+
}
687+
649688
if backendTcpProxyProtocolVersion, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "backend_tcp_proxy_protocol_version")); ok {
650689
tmp := backendTcpProxyProtocolVersion.(int)
651690
// Terraform v11 will auto assign nil value to 0 which is invalid value
@@ -670,6 +709,10 @@ func (s *LoadBalancerListenerResourceCrud) mapToConnectionConfiguration(fieldKey
670709
func ConnectionConfigurationToMap(obj *oci_load_balancer.ConnectionConfiguration) map[string]interface{} {
671710
result := map[string]interface{}{}
672711

712+
if obj.BackendTcpProxyProtocolOptions != nil {
713+
result["backend_tcp_proxy_protocol_options"] = toString(obj.BackendTcpProxyProtocolOptions)
714+
}
715+
673716
if obj.BackendTcpProxyProtocolVersion != nil {
674717
result["backend_tcp_proxy_protocol_version"] = int(*obj.BackendTcpProxyProtocolVersion)
675718
}

website/docs/d/load_balancer_load_balancers.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ The following attributes are exported:
127127

128128
The values must be between minimumBandwidthInMbps and 8000 (8Gbps).
129129

130-
Example: `1500`
131-
* `minimum_bandwidth_in_mbps` - Bandwidth in Mbps that determines the total pre-provisioned bandwidth (ingress plus egress). The values must be between 10 and the maximumBandwidthInMbps. Example: `150`
130+
Example: `1500`
131+
* `minimum_bandwidth_in_mbps` - Bandwidth in Mbps that determines the total pre-provisioned bandwidth (ingress plus egress). The values must be between 0 and the maximumBandwidthInMbps in multiples of 10. The current allowed maximum value is defined in [Service Limits](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/servicelimits.htm). Example: `150`
132132
* `ssl_cipher_suites` - The configuration details of an SSL cipher suite.
133133

134134
The algorithms that compose a cipher suite help you secure Transport Layer Security (TLS) or Secure Socket Layer (SSL) network connections. A cipher suite defines the list of security algorithms your load balancer uses to negotiate with peers while sending and receiving information. The cipher suites you use affect the security level, performance, and compatibility of your data traffic.

website/docs/r/load_balancer_listener.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ resource "oci_load_balancer_listener" "test_listener" {
2929
idle_timeout_in_seconds = var.listener_connection_configuration_idle_timeout_in_seconds
3030
3131
#Optional
32+
backend_tcp_proxy_protocol_options = var.listener_connection_configuration_backend_tcp_proxy_protocol_options
3233
backend_tcp_proxy_protocol_version = var.listener_connection_configuration_backend_tcp_proxy_protocol_version
3334
}
3435
hostname_names = [oci_load_balancer_hostname.test_hostname.name]
@@ -55,6 +56,7 @@ resource "oci_load_balancer_listener" "test_listener" {
5556
The following arguments are supported:
5657

5758
* `connection_configuration` - (Optional) (Updatable) Configuration details for the connection between the client and backend servers.
59+
* `backend_tcp_proxy_protocol_options` - (Optional) (Updatable) An array that represents the PPV2 Options that can be enabled on TCP Listeners. Example: ["PP2_TYPE_AUTHORITY"]
5860
* `backend_tcp_proxy_protocol_version` - (Required when `protocol` = `TCP`) (Updatable) The backend TCP Proxy Protocol version. Example: `1`
5961
* `idle_timeout_in_seconds` - (Required) (Updatable) The maximum idle time, in seconds, allowed between two successive receive or two successive send operations between the client and backend servers. A send operation does not reset the timer for receive operations. A receive operation does not reset the timer for send operations.
6062

0 commit comments

Comments
 (0)