Skip to content
Home / Migrations / AWS S3Cloudflare R2

AWS S3 Cloudflare R2

easy

R2 has zero egress fees vs S3's $0.09/GB. R2 is S3-compatible — just change the endpoint. Ideal for assets served to users.

Estimated: 1-3h · 5 steps
Progress0%
Step 1: Create R2 bucket

Cloudflare Dashboard → R2 → Create Bucket. Note the account ID.

Step 2: Create API token

R2 → Manage API Tokens → Create API Token with R2 permissions.

Step 3: Update SDK config

R2 is S3-compatible. Change endpoint, keep the same AWS SDK.

const r2 = new S3Client({
  region: 'auto',
  endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
  credentials: { accessKeyId: R2_ACCESS_KEY, secretAccessKey: R2_SECRET_KEY }
})
Step 4: Migrate existing objects

Use rclone to copy objects from S3 to R2.

rclone copy s3:my-bucket r2:my-bucket --transfers 32
Step 5: Update URLs

Enable public R2 domain or custom domain. Update any hardcoded S3 URLs.

Objects accessible, uploads working, zero egress charges

What this migration involves

Moving from AWS S3 to Cloudflare R2 is rated easy and takes about 1-3h on a typical project. The guide breaks it into 5 steps, 2 of which ship with runnable commands and 1 with a verification check. On pricing, AWS S3 is paid and Cloudflare R2 is freemium with a free plan to test the move.

FAQ

How long does migrating from AWS S3 to Cloudflare R2 take?

Around 1-3h for a typical project — 5 steps, difficulty rated easy, 2 of them with copy-paste commands.

Is moving from AWS S3 to Cloudflare R2 reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your AWS S3 data before you start.

What does Cloudflare R2 cost compared to AWS S3?

AWS S3: paid from $0/mo. Cloudflare R2: freemium from $0/mo, free plan available.