Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docs for lb listener and pool #923

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/resources/lb_listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following arguments are supported:
If omitted, the provider-level region will be used.
Changing this creates a new listener.

* `protocol` - (Required, String, ForceNew) The protocol can either be TCP, HTTP, HTTPS or TERMINATED_HTTPS.
* `protocol` - (Required, String, ForceNew) The protocol can either be TCP, UDP, HTTP or TERMINATED_HTTPS.
Changing this creates a new listener.

* `protocol_port` - (Required, Int, ForceNew) The port on which to listen for client traffic.
Expand Down
7 changes: 6 additions & 1 deletion docs/resources/lb_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ The following arguments are supported:

* `description` - (Optional, String) Human-readable description for the pool.

* `protocol` - (Required, String, ForceNew) The protocol - can either be TCP, HTTP or HTTPS.
* `protocol` - (Required, String, ForceNew) The protocol - can either be TCP, UDP or HTTP.

- When the protocol used by the listener is UDP, the protocol of the backend pool must be UDP.
- When the protocol used by the listener is TCP, the protocol of the backend pool must be TCP.
- When the protocol used by the listener is HTTP or TERMINATED_HTTPS, the protocol of the backend pool must be HTTP.

Changing this creates a new pool.

* `loadbalancer_id` - (Optional, String, ForceNew) The load balancer on which to provision this
Expand Down
2 changes: 1 addition & 1 deletion huaweicloud/resource_huaweicloud_lb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ResourceListenerV2() *schema.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"TCP", "UDP", "HTTP", "HTTPS", "TERMINATED_HTTPS",
"TCP", "UDP", "HTTP", "TERMINATED_HTTPS",
}, false),
},

Expand Down
41 changes: 13 additions & 28 deletions huaweicloud/resource_huaweicloud_lb_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/lbaas_v2/pools"
)
Expand Down Expand Up @@ -53,14 +54,9 @@ func ResourcePoolV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "TCP" && value != "HTTP" && value != "HTTPS" {
errors = append(errors, fmt.Errorf(
"Only 'TCP', 'HTTP', and 'HTTPS' are supported values for 'protocol'"))
}
return
},
ValidateFunc: validation.StringInSlice([]string{
"TCP", "UDP", "HTTP",
}, false),
},

// One of loadbalancer_id or listener_id must be provided
Expand All @@ -80,14 +76,9 @@ func ResourcePoolV2() *schema.Resource {
"lb_method": {
Type: schema.TypeString,
Required: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "ROUND_ROBIN" && value != "LEAST_CONNECTIONS" && value != "SOURCE_IP" {
errors = append(errors, fmt.Errorf(
"Only 'ROUND_ROBIN', 'LEAST_CONNECTIONS', and 'SOURCE_IP' are supported values for 'lb_method'"))
}
return
},
ValidateFunc: validation.StringInSlice([]string{
"ROUND_ROBIN", "LEAST_CONNECTIONS", "SOURCE_IP",
}, false),
},

"persistence": {
Expand All @@ -100,14 +91,9 @@ func ResourcePoolV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "SOURCE_IP" && value != "HTTP_COOKIE" && value != "APP_COOKIE" {
errors = append(errors, fmt.Errorf(
"Only 'SOURCE_IP', 'HTTP_COOKIE', and 'APP_COOKIE' are supported values for 'persistence'"))
}
return
},
ValidateFunc: validation.StringInSlice([]string{
"SOURCE_IP", "HTTP_COOKIE", "APP_COOKIE",
}, false),
},

"cookie_name": {
Expand Down Expand Up @@ -147,14 +133,13 @@ func resourcePoolV2Create(d *schema.ResourceData, meta interface{}) error {
if persistence.Type == "APP_COOKIE" {
if pV["cookie_name"].(string) == "" {
return fmt.Errorf(
"Persistence cookie_name needs to be set if using 'APP_COOKIE' persistence type.")
} else {
persistence.CookieName = pV["cookie_name"].(string)
"Persistence cookie_name needs to be set if using 'APP_COOKIE' persistence type")
}
persistence.CookieName = pV["cookie_name"].(string)
} else {
if pV["cookie_name"].(string) != "" {
return fmt.Errorf(
"Persistence cookie_name can only be set if using 'APP_COOKIE' persistence type.")
"Persistence cookie_name can only be set if using 'APP_COOKIE' persistence type")
}
}
}
Expand Down