Overview

Cloudflare R2 offers S3-compatible object storage with zero egress fees, making it an attractive alternative for applications with high bandwidth requirements. Migrating from AWS S3 to R2 can significantly reduce your cloud storage costs while maintaining compatibility with existing tools.

Why Cloudflare R2?

Zero egress fees, S3-compatible API, global distribution via Cloudflare's network, and seamless integration with Cloudflare Workers.

Prerequisites

  • A Cloney account with an active subscription
  • AWS S3 bucket with data to migrate
  • Cloudflare account with R2 enabled
  • Appropriate credentials for both services

Step 1: Add Your AWS S3 Source

  1. Log in to your Cloney dashboard
  2. Navigate to JobsCreate New Job
  3. Select AWS S3 as your source provider
  4. Enter your AWS credentials:
    • Access Key ID: Your IAM user access key
    • Secret Access Key: Your IAM user secret key
    • Region: The AWS region where your bucket is located
    • Bucket Name: The name of your source S3 bucket
  5. Click Validate Connection to verify access

Step 2: Configure Your Cloudflare R2 Destination

  1. Select Cloudflare R2 as your destination provider
  2. Enter your R2 credentials:
    • Account ID: Your Cloudflare account ID
    • Access Key ID: Your R2 API token access key
    • Secret Access Key: Your R2 API token secret key
    • Bucket Name: The name of your destination R2 bucket
  3. Click Validate Connection to verify access
Finding Your Account ID

Your Cloudflare Account ID can be found in the Cloudflare dashboard URL or in the R2 section under "Account ID".

Step 3: Configure Migration Options

Customize your migration with these options:

OptionDescriptionRecommendation
Prefix/Path FilterMigrate only objects matching a specific prefixUse for partial migrations
Preserve MetadataCopy object metadata along with dataEnable for full fidelity
Overwrite ExistingReplace objects that already exist in destinationEnable for sync operations

Step 4: Start the Migration

  1. Review your migration configuration
  2. Click Start Migration
  3. Monitor progress in the Jobs dashboard
Migration Complete

Once finished, verify your data in the Cloudflare dashboard and update your applications to use the R2 endpoint.

Updating Your Application

Since Cloudflare R2 is S3-compatible, updating your application is straightforward:

JavaScript - Update S3 Client Configuration
// Before (AWS S3)
const s3Client = new S3Client({
  region: "us-east-1",
  credentials: {
    accessKeyId: "YOUR_AWS_KEY",
    secretAccessKey: "YOUR_AWS_SECRET"
  }
});

// After (Cloudflare R2)
const s3Client = new S3Client({
  region: "auto",
  endpoint: "https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com",
  credentials: {
    accessKeyId: "YOUR_R2_ACCESS_KEY",
    secretAccessKey: "YOUR_R2_SECRET_KEY"
  }
});

Cost Comparison

R2's pricing can significantly reduce costs, especially for egress-heavy workloads:

Cost ComponentAWS S3Cloudflare R2
Storage (per GB/month)$0.023$0.015
Egress (per GB)$0.09$0.00
Class A Operations (per 1M)$5.00$4.50
Class B Operations (per 1M)$0.40$0.36
Free Tier

R2 includes 10GB storage, 1 million Class A operations, and 10 million Class B operations free per month.

Best Practices

  • Leverage zero egress: R2's zero egress fees make it ideal for CDN origins, media delivery, and high-traffic applications.
  • Use Workers integration: Combine R2 with Cloudflare Workers for serverless data processing at the edge.
  • Configure custom domains: Set up custom domains for your R2 buckets for branded URLs.
  • Enable public access carefully: Use signed URLs or Workers for access control rather than making buckets fully public.
  • Monitor usage: Use Cloudflare Analytics to monitor your R2 usage and optimize costs.