Zone-Level Ruleset Import Uses Incorrect API Endpoint #4924
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.
triage/needs-information
Indicates an issue needs more information in order to work on it.
Confirmation
Terraform and Cloudflare provider version
Terraform Cloudflare Provider: v4.50.0 (also tested with v4.51.0)
Terraform Version: v1.9.8
Affected resource(s)
cloudflare_ruleset
Terraform configuration files
Link to debug output
https://gist.github.com/maheedharTumpudi/ecb34700753ca08ec6fe597ff73d3973
Panic output
No response
Expected output
Import successful
Actual output
╷
│ Error: error reading ruleset ID "b4ea950b77334357a9a3a5ba25448521"
│
│ Authentication error (10000)
Steps to reproduce
Use the terraform import command to import a zone-level ruleset: terraform import 'module.btuanalytics-com-static-redirect-rule.cloudflare_ruleset.static-redirect-rule' 'zones/a0f79b4c115310cf6189f9462908523a/b4ea950b77334357a9a3a5ba25448521'
Observe the debug logs showing that the provider makes a request to:
GET /client/v4/accounts/a0f79b4c115310cf6189f9462908523a/rulesets/b4ea950b77334357a9a3a5ba25448521
{
"success": false,
"errors": [
{
"code": 10000,
"message": "Authentication error"
}
]
}
GET /client/v4/zones/a0f79b4c115310cf6189f9462908523a/rulesets/b4ea950b77334357a9a3a5ba25448521
This request works and returns the expected response.
Additional factoids
The provider should correctly identify the scope of the ruleset as zone-level and make the API request to zones/<zone_id>/rulesets instead of accounts/<account_id>/rulesets.
Actual Behavior
The provider incorrectly uses the accounts/<account_id>/rulesets endpoint, causing the import to fail.
Relevant Debug Logs
2025-01-22T12:43:54.177+0530 [DEBUG] provider.terraform-provider-cloudflare_v4.51.0.exe: GET /client/v4/accounts/a0f79b4c115310cf6189f9462908523a/rulesets/b4ea950b77334357a9a3a5ba25448521 HTTP/1.1
2025-01-22T12:43:54.177+0530 [DEBUG] provider.terraform-provider-cloudflare_v4.51.0.exe: Host: api.cloudflare.com
References
No response
The text was updated successfully, but these errors were encountered: