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

cloudflare_r2_bucket import (and maybe usage, if it did work?) fails with EU jurisdiction #3330

Open
3 tasks done
punkeel opened this issue May 27, 2024 · 5 comments
Open
3 tasks done
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@punkeel
Copy link
Member

punkeel commented May 27, 2024

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

Using tf cloud.
1.8.4 (Workspace version is ~>1.8.0)

terraform-provider-cloudflare_v4.33.0

Affected resource(s)

  • cloudflare_r2_bucket

Terraform configuration files

resource "cloudflare_r2_bucket" "my_backups" {
  account_id = "..."
  name       = "..."
  location   = "eeur"
}

import {
  to = cloudflare_r2_bucket.my_backups
  id = "6be2041a37d48a9799c6aaaaaaaaaaaa/aaa-aaaaaa"
}

Link to debug output

https://gist.github.com/punkeel/38f002ea6667f759ef7af5fce9fe05eb (heavily redacted)

Panic output

│ Error: failed reading R2 bucket

│ The specified bucket does not exist. (10006)

Expected output

  • The R2 bucket is found & imported

Actual output

│ Error: failed reading R2 bucket

│ The specified bucket does not exist. (10006)

Steps to reproduce

  1. Create R2 bucket in dash with the EU Jurisdiction
  2. Try to import it in Terraform...

Additional factoids

All the other buckets in my account can be imported just fine. This is the only one with a jurisdiction.

Does the import command need a "hint" to know about jurisdictions?

dash seems to be sending cf-r2-jurisdiction when tf doesn't, related? curl to the same endpoint works... if I specify cf-r2-jurisdiction.

References

No response

@punkeel punkeel 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 May 27, 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.

Copy link
Contributor

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

@github-actions github-actions bot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 27, 2024
@punkeel
Copy link
Member Author

punkeel commented May 27, 2024

Some API responses for reference:

maxime@MacPro> curl 'https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/r2/buckets/' -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -s|jq .                        ~
{
  "success": true,
  "errors": [],
  "messages": [],
  "result": {
    "buckets": [
      {
        "name": "maxime-test-01",
        "creation_date": "2022-05-14T00:27:19.714Z"
      },
      {
        "name": "lala",
        "creation_date": "2022-05-14T00:27:32.184Z"
      },
      {
        "name": "lala-lala",
        "creation_date": "2023-11-25T22:39:07.000Z"
      },
      {
        "name": "lalalala",
        "creation_date": "2024-03-22T00:16:19.039Z"
      }
    ]
  }
}
maxime@MacPro> curl 'https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/r2/buckets/my-backups' -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -s|jq .             ~
{
  "success": false,
  "errors": [
    {
      "code": 10006,
      "message": "The specified bucket does not exist."
    }
  ],
  "messages": [],
  "result": null
}
maxime@MacPro> curl 'https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/r2/buckets/my-backups' -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -s -H "cf-r2-jurisdiction: eu"|jq .
{
  "success": true,
  "errors": [],
  "messages": [],
  "result": {
    "name": "eu_my-backups",
    "creation_date": "2023-11-15T22:31:41.738Z",
    "location": "EEUR",
    "storage_class": "Standard"
  }
}
maxime@MacPro> curl 'https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/r2/buckets' -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -s -H "cf-r2-jurisdiction: eu"|jq .
{
  "success": true,
  "errors": [],
  "messages": [],
  "result": {
    "buckets": [
      {
        "name": "my-backups",
        "creation_date": "2023-11-15T22:31:41.738Z"
      }
    ]
  }
}

Copy link
Contributor

Marking this issue as stale due to 30 days of inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label.
If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@jacobbednarz jacobbednarz removed lifecycle/stale triage/needs-information Indicates an issue needs more information in order to work on it. labels Jun 27, 2024
@joeodfinity
Copy link

Related to this, the provider is unable to flag the need to use an R2 jurisdiction header with cloudflare v4 API requests,

-H "cf-r2-jurisdiction: eu"

cloudflare_r2_buckets created with a jurisdiction restriction (which is separate from declaration of the region for the backend storage) are not visible in the API without that header in the API request.

In my case I have some globally visible buckets declared in R2 WEUR region (no jurisdiction flagged), and the cloudflare provider can see them for import, but I have a couple of additional WEUR buckets with EU jurisdiction flagged in the webui, and the terraform provider can't see/import those.

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.
Projects
None yet
Development

No branches or pull requests

3 participants