Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudflare_load_balancer_monitor rejects empty string for expected_body #447

Closed
SpamapS opened this issue Aug 19, 2019 · 1 comment · Fixed by #539
Closed

cloudflare_load_balancer_monitor rejects empty string for expected_body #447

SpamapS opened this issue Aug 19, 2019 · 1 comment · Fixed by #539

Comments

@SpamapS
Copy link

SpamapS commented Aug 19, 2019

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.12.6
+ provider.aws v2.24.0
+ provider.cloudflare v1.17.1
+ provider.template v2.1.2

Affected Resource(s)

Please list the resources as a list, for example:

  • cloudflare_load_balancer_monitor

Terraform Configuration Files

resource "cloudflare_load_balancer_monitor" "k8s_ingress" {
  type             = "https"
  method           = "GET"
  path             = "/healthz"
  port             = var.k8s_ingress_monitor_port
  expected_codes   = "200"
  expected_body    = ""
  timeout          = 3
  interval         = 60
  retries          = 3
  description      = "${var.project_name} Kubernetes Ingress Check"
  allow_insecure   = true
  follow_redirects = false
}

Debug Output

Skipping this, can add if needed, this is not an internal issue.

Panic Output

N/A

Expected Behavior

Empty string is a valid body to expect, so this should have cleanly created the resource.

Actual Behavior

Whether creating or modifying, this value is rejected

module.the_watch_platform.module.cloudflare_lb_monitor.cloudflare_load_balancer_monitor.k8s_ingress: Modifying... [id=3a0704af92a48e7d677627a4f53833d4]

Error: expected_body must be set

  on ../modules/cloudflare/lb_monitor/main.tf line 16, in resource "cloudflare_load_balancer_monitor" "k8s_ingress":
  16: resource "cloudflare_load_balancer_monitor" "k8s_ingress" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

N/A

References

This code here is the problem:

https://github.com/terraform-providers/terraform-provider-cloudflare/blob/master/cloudflare/resource_cloudflare_load_balancer_monitor.go#L170-L174

GetOk checks for a "non zero" value. But the only zero value possible in strings is the empty string: ""

You will need to mark this value as required, and use .Get(), to get the intended effect of requiring it to be set to something, but allowing empty string.

@michaelbinks
Copy link

michaelbinks commented Nov 18, 2019

Do we know when #448 or #539 are going to be merged? Im stuck with this same error unless anyone else knows of a workaround.

boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this issue Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants