Skip to content

Commit

Permalink
Add Consecutive_up and Consecutive_down for load_balancer_monitor res…
Browse files Browse the repository at this point in the history
…ource
  • Loading branch information
Nmishin committed Aug 27, 2023
1 parent ce97e48 commit 79b78ad
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/2723.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
load_balancer_monitor: add support for `consecutive_up`, `consecutive_down`
```
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ func resourceCloudflareLoadBalancerPoolMonitorCreate(ctx context.Context, d *sch
client := meta.(*cloudflare.API)

loadBalancerMonitor := cloudflare.LoadBalancerMonitor{
Timeout: d.Get("timeout").(int),
Type: d.Get("type").(string),
Interval: d.Get("interval").(int),
Retries: d.Get("retries").(int),
Timeout: d.Get("timeout").(int),
Type: d.Get("type").(string),
Interval: d.Get("interval").(int),
Retries: d.Get("retries").(int),
Consecutive_up: d.Get("consecutive_up").(int),
Consecutive_down: d.Get("consecutive_down").(int),
}

if description, ok := d.GetOk("description"); ok {
Expand Down Expand Up @@ -124,11 +126,13 @@ func resourceCloudflareLoadBalancerPoolMonitorUpdate(ctx context.Context, d *sch
client := meta.(*cloudflare.API)

loadBalancerMonitor := cloudflare.LoadBalancerMonitor{
ID: d.Id(),
Timeout: d.Get("timeout").(int),
Type: d.Get("type").(string),
Interval: d.Get("interval").(int),
Retries: d.Get("retries").(int),
ID: d.Id(),
Timeout: d.Get("timeout").(int),
Type: d.Get("type").(string),
Interval: d.Get("interval").(int),
Retries: d.Get("retries").(int),
Consecutive_up: d.Get("consecutive_up").(int),
Consecutive_down: d.Get("consecutive_down").(int),
}

if description, ok := d.GetOk("description"); ok {
Expand Down Expand Up @@ -246,6 +250,8 @@ func resourceCloudflareLoadBalancerPoolMonitorRead(ctx context.Context, d *schem

d.Set("description", loadBalancerMonitor.Description)
d.Set("interval", loadBalancerMonitor.Interval)
d.Set("consecutive_up", loadBalancerMonitor.Consecutive_up)
d.Set("consecutive_down", loadBalancerMonitor.Consecutive_down)
d.Set("method", loadBalancerMonitor.Method)
d.Set("port", int(loadBalancerMonitor.Port))
d.Set("retries", loadBalancerMonitor.Retries)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func TestAccCloudflareLoadBalancerMonitor_FullySpecified(t *testing.T) {
resource.TestCheckResourceAttr(name, "path", "/custom"),
resource.TestCheckResourceAttr(name, "header.#", "1"),
resource.TestCheckResourceAttr(name, "retries", "5"),
resource.TestCheckResourceAttr(name, "consecutive_up", "2"),
resource.TestCheckResourceAttr(name, "consecutive_down", "2"),
resource.TestCheckResourceAttr(name, "port", "8080"),
resource.TestCheckResourceAttr(name, "expected_body", "dead"),
resource.TestCheckResourceAttr(name, "probe_zone", zoneName),
Expand Down Expand Up @@ -424,6 +426,8 @@ resource "cloudflare_load_balancer_monitor" "%[3]s" {
path = "/custom"
interval = 60
retries = 5
consecutive_up = 2
consecutive_down = 2
port = 8080
description = "this is a very weird load balancer"
probe_zone = "%[1]s"
Expand Down
14 changes: 14 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_load_balancer_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ func resourceCloudflareLoadBalancerMonitorSchema() map[string]*schema.Schema {
Description: "Do not validate the certificate when monitor use HTTPS. Only valid if `type` is \"http\" or \"https\"",
},

"consecutive_down": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times.",
},

"consecutive_up": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "To be marked healthy the monitored origin must pass this healthcheck N consecutive times.",
},

"expected_body": {
Type: schema.TypeString,
Optional: true,
Expand Down

0 comments on commit 79b78ad

Please sign in to comment.