I’m using a combination of terraform and ansible for our automation needs. Right now I’m able to create the R2 storage buckets using the “aws_s3_bucket” terraform resource; which comes from the hashicorp/aws provider.
I’m also able to manage DNS for our domain using the “cloudflare_zone” and the “cloudflare_record” terraform resources which comes from the cloudflare/cloudflare provider.
However, how can I set a hostname in DNS to point to the R2 bucket? I was able to do this through Cloudflare’s console/web-ui/dashboard, I had to go to create a Custom Domain under Public access in the R2 settings and then it automatically created a DNS record in the zone and the hostname type was “R2”. I thought maybe I could just create the same type of DNS record using terraform’s “cloudflare_record” resource, but when i tried to set the type as “R2” I got an error about that not being recognized (it only wants A, CNAME, etc.). So can I create this public access custom domain using some other method?
I need to be able to automate (via a python script or a bash script using curl commands or ansible or terraform, etc.) creating an R2 bucket and then pointing a DNS record to it for some static web hosting.