cf-terraforming icon indicating copy to clipboard operation
cf-terraforming copied to clipboard

rate_limit action for js_challenge should not be putting timeout value in

Open gray1117 opened this issue 3 years ago • 1 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

0.6.3

Expected outcome

Use the below command to generate legitimate rate_limit configuration file: cf-terraforming generate --resource-type cloudflare_rate_limit --zone ${ZONE_ID} > rate_limit.tf

Actual outcome

When the below is used to generate rate_limit configuration and the action is either js_challenge or challenge, the timeout value is set to zero. cf-terraforming generate --resource-type cloudflare_rate_limit --zone ${ZONE_ID} > rate_limit.tf

... action { mode = "js_challenge" timeout = 0 } ...

The API reference guide says the below on timeout value (this value should not be supplied):

"min value:1 max value:86400 notes: If mode is challenge or js_challenge then the Zone Challenge Passage time is used and this value should not be supplied."

The zero value then causes terraform to error when issue terraform plan:

Error: expected action.0.timeout to be in the range (1 - 86400), got 0 with cloudflare_rate_limit.terraform_managed_resource_a76sdgyiufg7itfgqiytsfasdqwd, on rate_limit.tf line 65, in resource "cloudflare_rate_limit" "terraform_managed_resource_a76sdgyiufg7itfgqiytsfasdqwd": timeout = 0

The API does return the timeout value to be zero, however the API guide does say this value should not be supplied for js_challenge and challenge:

  "threshold": 150,
  "period": 600,
  "action": {
    "mode": "js_challenge",
    "timeout": 0
  }

Steps to reproduce

  1. generate rate_limit resources where the action mode is js_challenge or challenge cf-terraforming generate --resource-type cloudflare_rate_limit --zone ${ZONE_ID} > rate_limit.tf

  2. use this configuration file in terraform configuration and perform: terraform plan

References

No response

gray1117 avatar Feb 07 '22 13:02 gray1117

I do have the same problem. Thank you for flagging this error @gray1117

surajthapa12 avatar Mar 30 '23 18:03 surajthapa12