cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
786 stars 609 forks source link

cloudflare_api_token resource creation error #3227

Closed serrf0f closed 7 months ago

serrf0f commented 7 months ago

Confirmation

Terraform and Cloudflare provider version

Terraform v1.7.5 on darwin_amd64

Affected resource(s)

Terraform configuration files

resource "cloudflare_api_token" "private_bucket_rw" {
  name = "mybucket_rw"

  policy {
    permission_groups = [
      "6a018a9f2fc74eb6b293b0c548f38b39", # Workers R2 Storage Bucket Item Read
      "2efd5506f9c8494dacb1fa10a3e7d5b6", # Workers R2 Storage Bucket Item Write
    ]
    resources = {
      "com.cloudflare.edge.r2.bucket.*" = "*"
    }
  }
}

Link to debug output

https://gist.github.com/serrf0f/02e14d3305e26d0b00b8eef564a151c6

Panic output

No response

Expected output

The cloudflare_api_token is created.

Actual output

error creating Cloudflare API Token "mybucket_rw": Unauthorized to access requested resource (9109)

Steps to reproduce

  1. terraform init
  2. terraform apply

Additional factoids

I do have the Account > API Token > Edit included in my token.

Capture d’écran 2024-04-04 à 18 08 12

References

No response

github-actions[bot] commented 7 months ago

Terraform debug log detected :white_check_mark:

github-actions[bot] commented 7 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 7 months ago

the error message here is saying that the resource you have requested does not have permission to be accessed by the token you are using. this is not a Terraform specific issue as the Terraform provider is just another HTTP client so i'd recommend attempting to replicate and debug this without the provider by using the API directly. alternatively, you can view the network traffic from a browser that performs this behaviour to see what is missing.

if you're still having issues, you're best bet is to reach out to Cloudflare support for guidance. thanks!