Skip to content

Commit

Permalink
Merge pull request #205 from jacobbednarz/add-allow-insecure-and-foll…
Browse files Browse the repository at this point in the history
…ow-redirects-support-to-lb

Add `allow_insecure` and `follow_redirects` to load balancer monitor
  • Loading branch information
jacobbednarz authored Feb 24, 2019
2 parents 4d3de2a + 3df2870 commit d164409
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cloudflare/resource_cloudflare_load_balancer_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ func resourceCloudflareLoadBalancerMonitor() *schema.Resource {
ValidateFunc: validation.IntBetween(0, 65535),
},

"allow_insecure": {
Type: schema.TypeBool,
Optional: true,
},

"follow_redirects": {
Type: schema.TypeBool,
Optional: true,
},

"created_on": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -147,6 +157,14 @@ func resourceCloudflareLoadBalancerPoolMonitorCreate(d *schema.ResourceData, met
loadBalancerMonitor.Port = uint16(port.(int))
}

if allowInsecure, ok := d.GetOk("allow_insecure"); ok {
loadBalancerMonitor.AllowInsecure = allowInsecure.(bool)
}

if followRedirects, ok := d.GetOk("follow_redirects"); ok {
loadBalancerMonitor.FollowRedirects = followRedirects.(bool)
}

log.Printf("[DEBUG] Creating Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor)

r, err := client.CreateLoadBalancerMonitor(loadBalancerMonitor)
Expand Down Expand Up @@ -192,6 +210,14 @@ func resourceCloudflareLoadBalancerPoolMonitorUpdate(d *schema.ResourceData, met
loadBalancerMonitor.Port = uint16(port.(int))
}

if allowInsecure, ok := d.GetOk("allow_insecure"); ok {
loadBalancerMonitor.AllowInsecure = allowInsecure.(bool)
}

if followRedirects, ok := d.GetOk("follow_redirects"); ok {
loadBalancerMonitor.FollowRedirects = followRedirects.(bool)
}

log.Printf("[DEBUG] Update Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor)

_, err := client.ModifyLoadBalancerMonitor(loadBalancerMonitor)
Expand Down Expand Up @@ -240,6 +266,8 @@ func resourceCloudflareLoadBalancerPoolMonitorRead(d *schema.ResourceData, meta
d.Set("type", loadBalancerMonitor.Type)
d.Set("description", loadBalancerMonitor.Description)
d.Set("port", loadBalancerMonitor.Port)
d.Set("allow_insecure", loadBalancerMonitor.AllowInsecure)
d.Set("follow_redirects", loadBalancerMonitor.FollowRedirects)
d.Set("created_on", loadBalancerMonitor.CreatedOn.Format(time.RFC3339Nano))
d.Set("modified_on", loadBalancerMonitor.ModifiedOn.Format(time.RFC3339Nano))

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/load_balancer_monitor.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ resource "cloudflare_load_balancer_monitor" "test" {
header = "Host"
values = ["example.com"]
}
allow_insecure = false
follow_redirects = true
}
```

Expand All @@ -43,6 +45,8 @@ The following arguments are supported:
* `header` - (Optional) The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot be overridden. Fields documented below.
* `type` - (Optional) The protocol to use for the healthcheck. Currently supported protocols are 'HTTP' and 'HTTPS'. Default: "http".
* `description` - (Optional) Free text description.
* `allow_insecure` - (Optional) Do not validate the certificate when monitor use HTTPS.
* `follow_redirects` - (Optional) Follow redirects if returned by the origin.

**header** requires the following:

Expand Down

0 comments on commit d164409

Please sign in to comment.