Remote R2 backend · Cloudflare Terraform docs | Latest TMZ Celebrity News & Gossip | Watch TMZ Live Skip to content
Cloudflare Docs

Remote R2 backend

Cloudflare R2 and Terraform remote backends can interact with each other to provide a seamless experience for Terraform state management.

Cloudflare R2 is an object storage service that provides a highly available, scalable, and secure way to store and serve static assets, such as images, videos, and static websites. R2 has S3 API compatibility making it easy to integrate with existing cloud infrastructure and applications.

Prerequisites

Create R2 bucket

Using Wrangler, API, or Account View Dashboard create an R2 Bucket.

Terminal window
wrangler r2 bucket create <YOUR_BUCKET_NAME>

Create scoped bucket API keys

Next you will need to create a bucket scoped R2 API token with Object Read & Write permissions. To create an API token, do the following:

  1. In Account Home, select R2.
  2. Under Account details, select Manage R2 API tokens.
  3. Select Create API token.
  4. Select the R2 Token text to edit your API token name.
  5. Under Permissions, select the Object Read and Write permissions, then scope your token to your <YOUR_BUCKET_NAME> bucket.
  6. Select Create API Token.

After your token has been successfully created, review your Secret Access Key and Access Key ID values.

Define R2 backend

Update your cloudflare.tf file to include a backend for the <YOUR_BUCKET_NAME> bucket you created above.

terraform {
backend "s3" {
bucket = "<YOUR_BUCKET_NAME>"
key = "/some/key/terraform.tfstate"
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
access_key = "<YOUR_R2_ACCESS_KEY>"
secret_key = "<YOUR_R2_ACCESS_SECRET>"
endpoints = { s3 = "https://<YOUR_ACCOUNT_ID>.r2.cloudflarestorage.com" }
}
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4"
}
}
}
provider "cloudflare" {
# token pulled from $CLOUDFLARE_API_TOKEN
}
variable "account_id" { default = "<YOUR_ACCOUNT_ID>" }

Migrate state file to R2 backend

After updating your cloudflare.tf file you can issue the terraform init -reconfigure command to migrate from a local state to remote state.

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.