Skip to content

Commit

Permalink
Adds probe_zone argument to LB Monitor resource
Browse files Browse the repository at this point in the history
  • Loading branch information
riuvshyn committed Dec 30, 2020
1 parent 9879db9 commit df05381
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cloudflare/resource_cloudflare_load_balancer_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ func resourceCloudflareLoadBalancerMonitor() *schema.Resource {
Optional: true,
Computed: true,
},

"probe_zone": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -195,6 +200,12 @@ func resourceCloudflareLoadBalancerPoolMonitorCreate(d *schema.ResourceData, met
} else {
loadBalancerMonitor.Path = "/"
}

if probeZone, ok := d.GetOk("probe_zone"); ok {
loadBalancerMonitor.ProbeZone = probeZone.(string)
} else {
loadBalancerMonitor.ProbeZone = ""
}
}

log.Printf("[DEBUG] Creating Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor)
Expand Down Expand Up @@ -277,6 +288,12 @@ func resourceCloudflareLoadBalancerPoolMonitorUpdate(d *schema.ResourceData, met
} else {
loadBalancerMonitor.Path = "/"
}

if probeZone, ok := d.GetOk("probe_zone"); ok {
loadBalancerMonitor.ProbeZone = probeZone.(string)
} else {
loadBalancerMonitor.ProbeZone = ""
}
}

log.Printf("[DEBUG] Update Cloudflare Load Balancer Monitor from struct: %+v", loadBalancerMonitor)
Expand Down Expand Up @@ -323,6 +340,7 @@ func resourceCloudflareLoadBalancerPoolMonitorRead(d *schema.ResourceData, meta
d.Set("expected_codes", loadBalancerMonitor.ExpectedCodes)
d.Set("follow_redirects", loadBalancerMonitor.FollowRedirects)
d.Set("path", loadBalancerMonitor.Path)
d.Set("probe_zone", loadBalancerMonitor.ProbeZone)

if err := d.Set("header", flattenLoadBalancerMonitorHeader(loadBalancerMonitor.Header)); err != nil {
log.Printf("[WARN] Error setting header for load balancer monitor %q: %s", d.Id(), err)
Expand Down
2 changes: 2 additions & 0 deletions cloudflare/resource_cloudflare_load_balancer_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestAccCloudflareLoadBalancerMonitor_FullySpecified(t *testing.T) {
resource.TestCheckResourceAttr(name, "retries", "5"),
resource.TestCheckResourceAttr(name, "port", "8080"),
resource.TestCheckResourceAttr(name, "expected_body", "dead"),
resource.TestCheckResourceAttr(name, "probe_zone", "example.com"),
),
},
},
Expand Down Expand Up @@ -301,6 +302,7 @@ resource "cloudflare_load_balancer_monitor" "test" {
retries = 5
port = 8080
description = "this is a very weird load balancer"
probe_zone = "example.com"
header {
header = "Host"
values = ["example.com"]
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/load_balancer_monitor.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "cloudflare_load_balancer_monitor" "http_monitor" {
}
allow_insecure = false
follow_redirects = true
probe_zone = "example.com"
}
```

Expand Down Expand Up @@ -65,6 +66,7 @@ The following arguments are supported:
* `description` - (Optional) Free text description.
* `allow_insecure` - (Optional) Do not validate the certificate when monitor use HTTPS. Only valid if `type` is "http" or "https".
* `follow_redirects` - (Optional) Follow redirects if returned by the origin. Only valid if `type` is "http" or "https".
* `probe_zone` - (Optional) Assign this monitor to emulate the specified zone while probing. Only valid if `type` is "http" or "https".

**header** requires the following:

Expand Down

0 comments on commit df05381

Please sign in to comment.