Skip to content

Commit

Permalink
Add http2_enable parameter in lb_listener_v2 resource (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo authored Apr 20, 2020
1 parent 9251466 commit a05c57a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/huaweicloud/golangsdk v0.0.0-20200416034153-3d1c2830a7e3
github.com/huaweicloud/golangsdk v0.0.0-20200420005119-26758c26a741
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a
github.com/mitchellh/go-homedir v1.1.0
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKe
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huaweicloud/golangsdk v0.0.0-20200416034153-3d1c2830a7e3 h1:V3ohVf+/bBVWN+UapuySheatua7RaXMahCtcGWu3gww=
github.com/huaweicloud/golangsdk v0.0.0-20200416034153-3d1c2830a7e3/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw=
github.com/huaweicloud/golangsdk v0.0.0-20200420005119-26758c26a741 h1:sTpHMX/Clj7p090iZQnoCkE9FsI8CYq5JYbEJaxkZBg=
github.com/huaweicloud/golangsdk v0.0.0-20200420005119-26758c26a741/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw=
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a h1:FyS/ubzBR5xJlnJGRTwe7GUHpJOR4ukYK3y+LFNffuA=
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a/go.mod h1:uoIMjNxUfXi48Ci40IXkPRbghZ1vbti6v9LCbNqRgHY=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
13 changes: 13 additions & 0 deletions huaweicloud/resource_huaweicloud_lb_listener_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func resourceListenerV2() *schema.Resource {
Computed: true,
},

"http2_enable": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"default_tls_container_ref": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -117,6 +123,7 @@ func resourceListenerV2Create(d *schema.ResourceData, meta interface{}) error {
}

adminStateUp := d.Get("admin_state_up").(bool)
http2_enable := d.Get("http2_enable").(bool)
var sniContainerRefs []string
if raw, ok := d.GetOk("sni_container_refs"); ok {
for _, v := range raw.([]interface{}) {
Expand All @@ -133,6 +140,7 @@ func resourceListenerV2Create(d *schema.ResourceData, meta interface{}) error {
Description: d.Get("description").(string),
DefaultTlsContainerRef: d.Get("default_tls_container_ref").(string),
SniContainerRefs: sniContainerRefs,
Http2Enable: &http2_enable,
AdminStateUp: &adminStateUp,
}

Expand Down Expand Up @@ -197,6 +205,7 @@ func resourceListenerV2Read(d *schema.ResourceData, meta interface{}) error {
d.Set("admin_state_up", listener.AdminStateUp)
d.Set("default_pool_id", listener.DefaultPoolID)
d.Set("connection_limit", listener.ConnLimit)
d.Set("http2_enable", listener.Http2Enable)
d.Set("sni_container_refs", listener.SniContainerRefs)
d.Set("default_tls_container_ref", listener.DefaultTlsContainerRef)
d.Set("region", GetRegion(d, config))
Expand Down Expand Up @@ -238,6 +247,10 @@ func resourceListenerV2Update(d *schema.ResourceData, meta interface{}) error {
asu := d.Get("admin_state_up").(bool)
updateOpts.AdminStateUp = &asu
}
if d.HasChange("http2_enable") {
http2 := d.Get("http2_enable").(bool)
updateOpts.Http2Enable = &http2
}

// Wait for LoadBalancer to become active before continuing
lbID := d.Get("loadbalancer_id").(string)
Expand Down
5 changes: 3 additions & 2 deletions huaweicloud/resource_huaweicloud_lb_listener_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestAccLBV2Listener_basic(t *testing.T) {
Config: TestAccLBV2ListenerConfig_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckLBV2ListenerExists("huaweicloud_lb_listener_v2.listener_1", &listener),
resource.TestCheckResourceAttr(
"huaweicloud_lb_listener_v2.listener_1", "name", "listener_1"),
resource.TestCheckResourceAttr(
"huaweicloud_lb_listener_v2.listener_1", "connection_limit", "-1"),
),
Expand All @@ -31,7 +33,7 @@ func TestAccLBV2Listener_basic(t *testing.T) {
resource.TestCheckResourceAttr(
"huaweicloud_lb_listener_v2.listener_1", "name", "listener_1_updated"),
resource.TestCheckResourceAttr(
"huaweicloud_lb_listener_v2.listener_1", "connection_limit", "100"),
"huaweicloud_lb_listener_v2.listener_1", "name", "listener_1_updated"),
),
},
},
Expand Down Expand Up @@ -121,7 +123,6 @@ resource "huaweicloud_lb_listener_v2" "listener_1" {
name = "listener_1_updated"
protocol = "HTTP"
protocol_port = 8080
connection_limit = 100
admin_state_up = "true"
loadbalancer_id = "${huaweicloud_lb_loadbalancer_v2.loadbalancer_1.id}"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ github.com/hashicorp/terraform-plugin-sdk/internal/svchost
github.com/hashicorp/terraform-plugin-sdk/internal/svchost/auth
# github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/hashicorp/yamux
# github.com/huaweicloud/golangsdk v0.0.0-20200416034153-3d1c2830a7e3
# github.com/huaweicloud/golangsdk v0.0.0-20200420005119-26758c26a741
github.com/huaweicloud/golangsdk
github.com/huaweicloud/golangsdk/openstack
github.com/huaweicloud/golangsdk/openstack/antiddos/v1/antiddos
Expand Down
23 changes: 12 additions & 11 deletions website/docs/r/lb_listener_v2.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following arguments are supported:
`region` argument of the provider is used. Changing this creates a new
Listener.

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

* `protocol_port` - (Required) The port on which to listen for client traffic.
Expand All @@ -51,18 +51,18 @@ The following arguments are supported:
* `description` - (Optional) Human-readable description for the Listener.

* `connection_limit` - (Optional) The maximum number of connections allowed
for the Listener.
for the Listener. The value ranges from -1 to 2,147,483,647.
This parameter is reserved and has been not used.
Only the administrator can specify the maximum number of connections.

* `default_tls_container_ref` - (Optional) A reference to a Barbican Secrets
container which stores TLS information. This is required if the protocol
is `TERMINATED_HTTPS`. See
[here](https://wiki.openstack.org/wiki/Network/LBaaS/docs/how-to-create-tls-loadbalancer)
for more information.
* `http2_enable` - (Optional) Specifies whether to use HTTP/2. The default value is false.
This parameter is valid only when the protocol is set to `TERMINATED_HTTPS`.

* `sni_container_refs` - (Optional) A list of references to Barbican Secrets
containers which store SNI information. See
[here](https://wiki.openstack.org/wiki/Network/LBaaS/docs/how-to-create-tls-loadbalancer)
for more information.
* `default_tls_container_ref` - (Optional) Specifies the ID of the server certificate
used by the listener. This parameter is mandatory when protocol is set to `TERMINATED_HTTPS`.

* `sni_container_refs` - (Optional) Lists the IDs of SNI certificates (server certificates
with a domain name) used by the listener. This parameter is valid when protocol is set to `TERMINATED_HTTPS`.

* `admin_state_up` - (Optional) The administrative state of the Listener.
A valid value is true (UP) or false (DOWN).
Expand All @@ -79,6 +79,7 @@ The following attributes are exported:
* `default_port_id` - See Argument Reference above.
* `description` - See Argument Reference above.
* `connection_limit` - See Argument Reference above.
* `http2_enable` - See Argument Reference above.
* `default_tls_container_ref` - See Argument Reference above.
* `sni_container_refs` - See Argument Reference above.
* `admin_state_up` - See Argument Reference above.

0 comments on commit a05c57a

Please sign in to comment.