Skip to content

Commit

Permalink
LBAAS-2428 Support HTTP idle timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenVarela committed Nov 17, 2022
1 parent 286524f commit 9003be2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions digitalocean/resource_digitalocean_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ func resourceDigitalOceanLoadBalancerV0() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"http_idle_timeout_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: nil,
},
},
}
}
Expand Down Expand Up @@ -421,6 +427,14 @@ func buildLoadBalancerRequest(client *godo.Client, d *schema.ResourceData) (*god
opts.SizeSlug = d.Get("size").(string)
}

idleTimeout, ok := d.GetOk("http_idle_timeout_seconds")
if ok {
t := uint64(idleTimeout.(int))
opts.HTTPIdleTimeoutSeconds = &t
} else {
opts.HTTPIdleTimeoutSeconds = nil
}

if v, ok := d.GetOk("droplet_tag"); ok {
opts.Tag = v.(string)
} else if v, ok := d.GetOk("droplet_ids"); ok {
Expand Down Expand Up @@ -505,6 +519,8 @@ func resourceDigitalOceanLoadbalancerRead(ctx context.Context, d *schema.Resourc
d.Set("enable_backend_keepalive", loadbalancer.EnableBackendKeepalive)
d.Set("droplet_tag", loadbalancer.Tag)
d.Set("vpc_uuid", loadbalancer.VPCUUID)
d.Set("http_idle_timeout_seconds", loadbalancer.HTTPIdleTimeoutSeconds)

if loadbalancer.SizeUnit > 0 {
d.Set("size_unit", loadbalancer.SizeUnit)
} else {
Expand Down
7 changes: 7 additions & 0 deletions digitalocean/resource_digitalocean_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func TestAccDigitalOceanLoadbalancer_Basic(t *testing.T) {
"digitalocean_loadbalancer.foobar", "enable_backend_keepalive", "true"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "disable_lets_encrypt_dns_records", "false"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "http_idle_timeout_seconds", "60"),
),
},
},
Expand Down Expand Up @@ -152,6 +154,8 @@ func TestAccDigitalOceanLoadbalancer_Updated(t *testing.T) {
"digitalocean_loadbalancer.foobar", "enable_backend_keepalive", "true"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "disable_lets_encrypt_dns_records", "false"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "http_idle_timeout_seconds", "60"),
),
},
{
Expand Down Expand Up @@ -191,6 +195,8 @@ func TestAccDigitalOceanLoadbalancer_Updated(t *testing.T) {
"digitalocean_loadbalancer.foobar", "enable_backend_keepalive", "false"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "disable_lets_encrypt_dns_records", "true"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "http_idle_timeout_seconds", "60"),
),
},
},
Expand Down Expand Up @@ -728,6 +734,7 @@ resource "digitalocean_loadbalancer" "foobar" {
enable_proxy_protocol = true
enable_backend_keepalive = true
http_idle_timeout_seconds = 60
droplet_ids = [digitalocean_droplet.foobar.id]
}`, rInt, rInt)
Expand Down
1 change: 1 addition & 0 deletions docs/resources/loadbalancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ the backend service. Default value is `false`.
* `type` - (Required) An attribute indicating how and if requests from a client will be persistently served by the same backend Droplet. The possible values are `cookies` or `none`. If not specified, the default value is `none`.
* `cookie_name` - (Optional) The name to be used for the cookie sent to the client. This attribute is required when using `cookies` for the sticky sessions type.
* `cookie_ttl_seconds` - (Optional) The number of seconds until the cookie set by the Load Balancer expires. This attribute is required when using `cookies` for the sticky sessions type.
* `http_idle_timeout_seconds` - (Optional) The http idle timeout configuration in seconds. if not specified, this defaults to 60 seconds.


`healthcheck` supports the following:
Expand Down

0 comments on commit 9003be2

Please sign in to comment.