cloudflare / terraform-provider-cloudflare

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

Managing R2 objects #2762

Closed SvanteRichter closed 11 months ago

SvanteRichter commented 12 months ago

Current Terraform and Cloudflare provider version

Terraform v1.5.7 on linux_amd64

Description

Currently it seems like it is not possible to upload/manage R2 objects with terraform. As was noted by @yonran in #1664:

it seems that it is not possible to create a cloudflare object using terraform-provider-aws 4.x aws_s3_object (aka aws_s3_bucket_object), since that resource tries to read the tags using GetObjectTagging (GET /key?tagging=), but R2 does not recognize ?tagging and just returns the object itself.

Since the R2 S3 API does not support the required interface to use the AWS terraform provider and the cloudflare provider does not implement any object-level apis there is no way to manage R2 objects with terraform.

Use cases

I'm trying to upload objects for use with workers that I deploy with the cloudflare provider. It can be frontend resources, backend data, anything object-like that is coupled to a deployment of a worker.

Potential Terraform configuration

Either with the s3 provider (if the cloudflare s3 api starts supporting GetObjectTagging):

resource "aws_s3_object" "dist" {
  bucket = cloudflare_r2_bucket.main_bucket.name
  key    = "test.txt"
  source = "${path.module}/example/dist/test.txt"
  source_hash   = filemd5("${path.module}/example/dist/test.txt")
}

Or with a r2 object resource:

resource "cloudflare_r2_object" "dist" {
  bucket = cloudflare_r2_bucket.main_bucket.name
  key    = "test.txt"
  source = "${path.module}/example/dist/test.txt"
  source_hash   = filemd5("${path.module}/example/dist/test.txt")
}

References

1664 mentions the issue

github-actions[bot] commented 12 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 11 months ago

duplicate of #1664. there are still no plans to expose the S3 compatible API via the Go SDK so until such a time, this won't be possible.

SvanteRichter commented 11 months ago

@jacobbednarz Are there no plans to offer a cloudflare_r2_object or similar either? This feature request is just having any way to upload objects into an r2 bucket with terraform.