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

Can't set default ttl using a variable #3736

Open
3 tasks done
sanketwadekar3 opened this issue Aug 22, 2024 · 2 comments
Open
3 tasks done

Can't set default ttl using a variable #3736

sanketwadekar3 opened this issue Aug 22, 2024 · 2 comments
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

@sanketwadekar3
Copy link

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.4.2 on darwin_arm64
Cloudflare provider version 4.40.0

Affected resource(s)

cloudflare_ruleset

Terraform configuration files

resource "cloudflare_ruleset" "cache_example" {

  zone_id     = var.cloudflare_zone_id
  name        = "cache example"
  description = "Set cache settings for incoming requests"
  kind        = "zone"
  phase       = "http_request_cache_settings"

  rules {
    action = "set_cache_settings"
    action_parameters {
      edge_ttl {
        mode    = "override_origin"
        default = var.edge_ttl
      }
      browser_ttl {
        mode    = "override_origin"
        default = var.browser_ttl
      }
    }
    expression  = "(http.host eq \"example.host.com\")"
    description = "Set cache settings"
    enabled     = true
  }
}


variable "edge_ttl" {
  type        = number
  description = "cloudflare edge ttl"
  default     = 600
}

variable "browser_ttl" {
  type        = number
  description = "cloudflare browser ttl"
  default     = 300
}

Link to debug output

https://gist.github.com/sanketwadekar3/ab03cd9436085de788e75d65c4d6af6c

Panic output

No response

Expected output

The configuration is expected to be valid when we pass the ttl value from a variable.

Actual output

Error: invalid configuration

with cloudflare_ruleset.cache_rule,
on main.tf line 37, in resource "cloudflare_ruleset" "cache_example":
37: edge_ttl {
using mode 'override_origin' requires setting a default for ttl

Error: invalid configuration

with cloudflare_ruleset.cache_rule,
on main.tf line 41, in resource "cloudflare_ruleset" "cache_example":
41: browser_ttl {
using mode 'override_origin' requires setting a default for ttl

Steps to reproduce

  1. Create a cache rule that passes value to edge_ttl and browser_ttl using variables when mode is 'override_origin'.
  2. Run terraform plan
  3. You'll see an error indicating that 'override_origin' requires setting a default for ttl

Additional factoids

No response

References

No response

@sanketwadekar3 sanketwadekar3 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 Aug 22, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Aug 22, 2024
@Bass-03
Copy link

Bass-03 commented Sep 4, 2024

This started on 4.7 when you guys changed to terraform-plugin-framework here #2170

Why does it matter? We can not use cloudflare_ruleset in a module and add the ttf defaults via locals or variables, it only accepts hardcoded values.

Hence, we are pinning the cloudflare provider to 4.6 for the time being

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