Skip to content

Commit

Permalink
Support HTTP idle timeout & Project ID (#897)
Browse files Browse the repository at this point in the history
* Bump godo version

* Support HTTP idle timeout & project_id
  • Loading branch information
StephenVarela committed Nov 22, 2022
1 parent 2a413c8 commit dc5ff85
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 51 deletions.
21 changes: 21 additions & 0 deletions digitalocean/resource_digitalocean_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ func resourceDigitalOceanLoadBalancerV0() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"http_idle_timeout_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: nil,
},

"project_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
},
},
}
}
Expand Down Expand Up @@ -413,6 +425,7 @@ func buildLoadBalancerRequest(client *godo.Client, d *schema.ResourceData) (*god
EnableBackendKeepalive: d.Get("enable_backend_keepalive").(bool),
ForwardingRules: forwardingRules,
DisableLetsEncryptDNSRecords: godo.Bool(d.Get("disable_lets_encrypt_dns_records").(bool)),
ProjectID: d.Get("project_id").(string),
}
sizeUnit, ok := d.GetOk("size_unit")
if ok {
Expand All @@ -421,6 +434,12 @@ 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
}

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 +524,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
16 changes: 16 additions & 0 deletions digitalocean/resource_digitalocean_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ 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", "90"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "project_id", "my-project-uuid"),
),
},
},
Expand Down Expand Up @@ -152,6 +156,10 @@ 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", "90"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "project_id", "my-project-uuid"),
),
},
{
Expand Down Expand Up @@ -191,6 +199,10 @@ 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", "120"),
resource.TestCheckResourceAttr(
"digitalocean_loadbalancer.foobar", "project_id", "my-project-uuid"),
),
},
},
Expand Down Expand Up @@ -728,6 +740,8 @@ resource "digitalocean_loadbalancer" "foobar" {
enable_proxy_protocol = true
enable_backend_keepalive = true
http_idle_timeout_seconds = 90
project_id = "my-project-uuid"
droplet_ids = [digitalocean_droplet.foobar.id]
}`, rInt, rInt)
Expand Down Expand Up @@ -769,6 +783,8 @@ resource "digitalocean_loadbalancer" "foobar" {
enable_proxy_protocol = false
enable_backend_keepalive = false
disable_lets_encrypt_dns_records = true
http_idle_timeout_seconds = 120
project_id = "my-project-uuid"
droplet_ids = [digitalocean_droplet.foobar.id, digitalocean_droplet.foo.id]
}`, rInt, 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/digitalocean/terraform-provider-digitalocean

require (
github.com/aws/aws-sdk-go v1.42.18
github.com/digitalocean/godo v1.87.0
github.com/digitalocean/godo v1.90.0
github.com/hashicorp/awspolicyequivalence v1.5.0
github.com/hashicorp/go-uuid v1.0.2
github.com/hashicorp/go-version v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/godo v1.87.0 h1:U6jyE7Ga+6NkAa8pnpgrKk0lEU1e3Fc/kWipC9tARds=
github.com/digitalocean/godo v1.87.0/go.mod h1:NRpFznZFvhHjBoqZAaOD3khVzsJ3EibzKqFL4R60dmA=
github.com/digitalocean/godo v1.90.0 h1:mnluEWL5eXFNYnLzHFuwsPuXZsWmzGoMNYSLZi9QPgc=
github.com/digitalocean/godo v1.90.0/go.mod h1:NRpFznZFvhHjBoqZAaOD3khVzsJ3EibzKqFL4R60dmA=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down
22 changes: 22 additions & 0 deletions vendor/github.com/digitalocean/godo/CHANGELOG.md

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

16 changes: 4 additions & 12 deletions vendor/github.com/digitalocean/godo/apps.gen.go

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

47 changes: 47 additions & 0 deletions vendor/github.com/digitalocean/godo/apps.go

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

48 changes: 16 additions & 32 deletions vendor/github.com/digitalocean/godo/apps_accessors.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/digitalocean/godo/droplet_actions.go

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

Loading

0 comments on commit dc5ff85

Please sign in to comment.