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_pool origin header override inconsistent result after apply #4828

Closed
3 tasks done
steve-hb opened this issue Jan 3, 2025 · 3 comments
Closed
3 tasks done
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.

Comments

@steve-hb
Copy link

steve-hb commented Jan 3, 2025

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.10.3
on darwin_arm64

  • provider registry.terraform.io/cloudflare/cloudflare v5.0.0-alpha1

Latest as of writing this

Affected resource(s)

cloudflare_load_balancer_pool#origins

Terraform configuration files

terraform {
  required_version = ">= v1.10.3"

  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
      version = "5.0.0-alpha1"
    }
  }
}

locals {
    random_string = "2432425254235"

    domain = "test.<my-domain>"
    base_domain = "<my-domain>"
    ipv6_address = "<valid-ipv6>"
}

variable "cloudflare_api_token" {
  type = string
  default = "<my-api-token>"
  sensitive = true
}

variable "cloudflare_account_id" {
  type = string
  default = "<my-account-id>"
  sensitive = true
}

provider "cloudflare" {
  api_token = var.cloudflare_api_token
}

resource "cloudflare_load_balancer_monitor" "monitor" {
  description = "Health check for monitoring cluster nodes"
  type        = "http"
  port        = 80
  method      = "GET"
  path        = "/api/health"
  expected_codes = "200"
  interval       = 60
  allow_insecure   = true # TODO: Remove this

  account_id = var.cloudflare_account_id
}

resource "cloudflare_load_balancer_pool" "pool" {
  name    = "monitoring-cluster-pool-${local.random_string}"
  monitor = cloudflare_load_balancer_monitor.monitor.id

  origins = [{
      name    = "node"
      address = local.ipv6_address
      header  = {
        header = "Host"
        values = [local.ipv6_address] # actually uses a domain name in my scripts
      } # TODO: The Cloudflare provider currently seems to be buggy about this
      enabled = true
      weight  = 1
  }]

  account_id = var.cloudflare_account_id
}


data "cloudflare_zone" "domain" {
  filter = {
    name = local.base_domain
  }
}

resource "cloudflare_dns_record" "monitoring_nodes" {
  zone_id = data.cloudflare_zone.domain.id
  name    = "node"
  content   = local.ipv6_address
  type    = "AAAA"
  proxied = false
  ttl     = 60
}

resource "cloudflare_load_balancer" "lb" {
  zone_id          = data.cloudflare_zone.domain.id
  name             = "${local.domain}"
  default_pools = [cloudflare_load_balancer_pool.pool.id]
  fallback_pool = cloudflare_load_balancer_pool.pool.id
  enabled          = true
  proxied          = true
  session_affinity = "cookie"

  depends_on       = [cloudflare_load_balancer_pool.pool]
}

Link to debug output

https://gist.github.com/steve-hb/1caac160b9937d079027ab7ef6fb9165

Panic output

No response

Expected output

It should create a LoadBalancer with the origin headers overridden for each origin.

Actual output

The provider fails due to inconsistent result.

Steps to reproduce

Add your api_token and account_id and finally apply the file.

Additional factoids

I tried multiple ways of defining the headers from different sources I found, one (I provided) directly set an object, others defined it as an array of objects (makes sense):

header  = [{
            header = "Host"
            values = [local.ipv6_address] # actually uses a domain name in my scripts
        }]

The direct object approach nevertheless is imo consistent with this destroy output when using the officially documented way of defining an array:

Error: Incorrect attribute value type
│ 
│   on main.tf line 55, in resource "cloudflare_load_balancer_pool" "pool":
│   55:   origins = [{
│   56:       name    = "node"
│   57:       address = local.ipv6_address
│   58:       header  = [
│   59:         {
│   60:             header = "Host"
│   61:             values = [local.ipv6_address]
│   62:         }
│   63:       ] # TODO: The Cloudflare provider currently seems to be buggy about this
│   64:       enabled = true
│   65:       weight  = 1
│   66:   }]
│     ├────────────────│ 
│ Inappropriate value for attribute "origins": element 0: attribute "header": object required.

The result (failure) stays the same no matter how I configure it.

Setting the Header override manually in the Cloudflare dashboard works fine and as expected.

References

https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/load_balancer_pool#example-usage shows how to use it

@steve-hb steve-hb added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Terraform debug log detected ✅

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@jacobbednarz
Copy link
Member

5.0.0-alpha1 has known issues and will be addressed in later releases. we're not accepting new bugs at this point as the upcoming releases dramatically improve the situation. you can try a custom build on the next branch if you want to see if this is already addressed.

@jacobbednarz jacobbednarz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Projects
None yet
Development

No branches or pull requests

2 participants