Files
code-snippets/docs/terraform/remote-state-cloudflare-r2.md
Liam Pietralla 30ffa17752
All checks were successful
Build, Test & Publish / Build and Publish Container Image (push) Successful in 2m45s
Build, Test & Publish / Build (push) Successful in 1m37s
Build, Test & Publish / Deploy to Infrastructure (push) Successful in 30s
r2 remote state
2026-03-26 17:38:11 +11:00

744 B

Remote State with Cloudflare R2

The following is an example of how to use Cloudflare R2 as a remote state backend for Terraform. This allows you to store your Terraform state files in Cloudflare's object storage service, providing durability and accessibility.

terraform {
  backend "s3" {
    bucket = "<BUCKET_NAME>"
    key    = "<UNIQUE_APP>/terraform.tfstate"

    endpoints = {
      s3 = "https://<BUCKET_ID>.r2.cloudflarestorage.com"
    }

    region                      = "auto"
    skip_credentials_validation = true
    skip_metadata_api_check     = true
    skip_region_validation      = true
    skip_requesting_account_id  = true
    skip_s3_checksum            = true
    use_path_style              = true
  }
}