-
Notifications
You must be signed in to change notification settings - Fork 619
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
Resources for managing R2 #1664
Comments
@jacobbednarz can you elaborate what upstream movement we're jammed on? I can programmatically manipulate buckets with |
the upstream library that Terraform uses to make the API calls - cloudflare-go. |
Disappointed to see there's no support for buckets w/terraform. |
If you just want to create buckets, you can use the terraform-provider-aws with the S3 Compatibility API and an S3 Auth token, and using a custom service endpoint and skipping sanity checks within the
However, it seems that it is still not possible to bind a bucket to a Edit: it seems that it is not possible to create a cloudflare object using terraform-provider-aws 4.x |
I am using this provider solely to create Cloudflare buckets and objects, since terraform-provider-cloudflare does not have support yet (cloudflare/terraform-provider-cloudflare#1664). But since the CloudFlare provider does not support the ?tagging api, this commit removes that functionality from aws_s3_object.
@jacobbednarz @andyli https://pkg.go.dev/github.com/cloudflare/cloudflare-go#API.CreateR2Bucket Example here: |
Looking forward to this. +1 |
Looking forwad as well now that R2 is GA. |
FYI, this still isn't possible as there is no publicly documented API end to get a bucket which terraform needs to check to see if a resource exists. |
When this does get implemented, having CORS support baked-in would be great: https://kian.org.uk/configuring-cors-on-cloudflare-r2/ |
@jpalomaki that may be possible using the AWS provider to configure the R2 bucket (I haven't tried yet but I plan on it): https://developers.cloudflare.com/r2/examples/terraform/ |
I have found the following aws resources seem to work fine:
|
@jpalomaki I recently got configuring CORS with terraform working: terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.57.1"
}
}
}
provider "aws" {
alias = "cloudflare"
region = "us-east-1"
access_key = var.cloudflare_r2_access_key
secret_key = var.cloudflare_r2_secret_key
skip_credentials_validation = true
skip_region_validation = true
skip_requesting_account_id = true
endpoints {
s3 = var.cloudflare_r2_endpoint
}
}
resource "aws_s3_bucket" "public_bucket" {
provider = aws.cloudflare
bucket = var.cloudflare_r2_public_bucket
}
resource "aws_s3_bucket_cors_configuration" "public_bucket_cors" {
provider = aws.cloudflare
bucket = aws_s3_bucket.public_bucket.id
cors_rule {
allowed_methods = ["GET"]
allowed_origins = ["*"]
}
} |
Would be great to be able to configure Domain Access as well, since it currently doesn't seem to be possible to set some required metadata with cloudflare_record, like which R2 bucket the DNS record points to (Even though importing R2 records works just fine). |
This functionality has been released in v4.7.0 of the Terraform Cloudflare Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Current Terraform and Cloudflare provider version
N/A
Description
Would be nice to have resources for managing R2 buckets.
Use cases
To manage everything in Terraform.
Potential Terraform configuration
Something similar to the aws_s3_bucket and the related resources.
References
No response
The text was updated successfully, but these errors were encountered: