Skip to content

cloudflare_ruleset example lists id which is a read-only field #5666

@chaswag

Description

@chaswag

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

The cloudflare provider 5.5.0 cloudflare_ruleset documentation includes an example config with a rule specification that contains a read-only attribute. In the example config:

  rules = [{
    id = "3a03d665bac047339bb530ecb439a90d"
...

Running terraform plan on the example config will produce this error:

│ Error: Invalid Configuration for Read-Only Attribute
│ 
│   with cloudflare_ruleset. example_ruleset,
│   on cloudflare.tf line 2, in resource "cloudflare_ruleset" "example_ruleset":
│    2: resource "cloudflare_ruleset" "example_ruleset" {
│ 
│ Cannot set value for this attribute as the provider has marked it as read-only. Remove the configuration line setting the value.
│ 
│ Refer to the provider documentation or contact the provider developers for additional information about configurable and read-only attributes that are supported.

Remove the id reference from the example code.

Affected resource(s)

cloudflare_ruleset

Terraform configuration files

resource "cloudflare_ruleset" "example_ruleset" {
  kind = "root"
  name = "My ruleset"
  phase = "http_request_firewall_custom"
  zone_id = "zone_id"
  description = "My ruleset to execute managed rulesets"
  rules = [{
    id = "3a03d665bac047339bb530ecb439a90d"
    action = "block"
    action_parameters = {
      response = {
        content = <<EOT
        {
          "success": false,
          "error": "you have been blocked"
        }
        EOT
        content_type = "application/json"
        status_code = 400
      }
    }
    description = "Block when the IP address is not 1.1.1.1"
    enabled = true
    exposed_credential_check = {
      password_expression = "url_decode(http.request.body.form[\\\"password\\\"][0])"
      username_expression = "url_decode(http.request.body.form[\\\"username\\\"][0])"
    }
    expression = "ip.src ne 1.1.1.1"
    logging = {
      enabled = true
    }
    ratelimit = {
      characteristics = ["ip.src"]
      period = 60
      counting_expression = "http.request.body.raw eq \"abcd\""
      mitigation_timeout = 600
      requests_per_period = 1000
      requests_to_origin = true
      score_per_period = 400
      score_response_header_name = "my-score"
    }
    ref = "my_ref"
  }]
}

Link to debug output

n/a

Panic output

No response

Expected output

terraform plan output

Actual output

│ Error: Invalid Configuration for Read-Only Attribute

│ with cloudflare_ruleset.example_ruleset,
│ on cloudflare.tf line 2, in resource "cloudflare_ruleset" "example_ruleset":
│ 2: resource "cloudflare_ruleset" "example_ruleset" {

│ Cannot set value for this attribute as the provider has marked it as read-only. Remove the configuration line setting the value.

│ Refer to the provider documentation or contact the provider developers for additional information about configurable and read-only
│ attributes that are supported.

Steps to reproduce

Follow the example in the doc

Additional factoids

No response

References

https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/ruleset

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions