Welcome to Centmin Mod Community
Become a Member

Cloudflare Cloudflare Platform Week May 2022 - Cache Reserve & R2 S3 Object Storage

Discussion in 'Domains, DNS, Email & SSL Certificates' started by eva2000, May 14, 2022.

  1. eva2000

    eva2000 Administrator Staff Member

    48,519
    11,116
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,306
    Local Time:
    5:56 AM
    Nginx 1.21.x
    MariaDB 10.x
    Cloudflare Platform Week this week reveal lots of cool new product and service offerings. There are still some announcements for tomorrow. But I'm excited by 2 announcements.
    • Cloudflare R2 S3 API compatible object storage like Backblaze's B2, Amazon S3 or DigitalOcean or Linode's S3 object storage. But Cloudflare R2 has free egress bandwidth charges more suited to hot cache like usage rather than for storage itself. I've already updated my custom AWS CLI client's install and profile setup script to support Cloudflare R2 S3 API at https://awscli-get.centminmod.com/ :D
    • Cloudflare Cache Reserve to extend how long Cloudflare stores your defined cached assets by storing and syncing cached assets with Cloudflare R2 S3 bucket.
    For Cloudflare Cache Reserve

    Cloudflare Cache Reserve

    cf-cache-reserve-01.png

    cf-cache-reserve-03.png

    Cloudflare R2 S3 object storage

    cf-r2-api-tokens-01.png

    cf-r2-api-tokens-02.png

    cf-r2-create-bucket-01.png

    cf-r2-create-bucket-02.png

    My AWS CLI install and profile setup script example setting up Cloudflare R2 profile. The script will automatically apply some additional configuration adjustments specifically for max_concurrent_requests = 2, multipart_threshold = 50MB, multipart_chunksize = 50MB and addressing_style = path to ensure Cloudflare R2 is working properly :)

    Code (Text):
    export AWS_ACCESS_KEY_ID=CF_R2_ACCESS_KEY_ID
    export AWS_SECRET_ACCESS_KEY=CF_R2_SECRET_ACCESS_KEY
    export AWS_DEFAULT_REGION=auto
    export AWS_DEFAULT_OUTPUT=text
    
    ./awscli-get.sh install r2
    
    existing config file detected: /root/.aws/config
    existing credential file detected: /root/.aws/credentials
    
    configure aws-cli profile: r2
    configure aws cli for Cloudflare R2
    aws configure set s3.max_concurrent_requests 2 --profile r2
    aws configure set s3.multipart_threshold 50MB --profile r2
    aws configure set s3.multipart_chunksize 50MB --profile r2
    aws configure set s3.addressing_style path --profile r2
    
    aws-cli profile: r2 set:
    
    aws_access_key_id: CF_R2_ACCESS_KEY_ID
    aws_secret_access_key: CF_R2_SECRET_ACCESS_KEY
    default.region: auto
    default output format: text
    
    list aws-cli profiles:
    
    default
    r2
    


    Example usage uploading test.txt file and listing it.
    Code (Text):
    aws s3 cp test.txt --profile r2 --endpoint-url=https://YOUR_CF_ACCOUNT_ID.r2.cloudflarestorage.com s3://YOUR_R2_BUCKET_NAME
    upload: ./test.txt to s3://YOUR_R2_BUCKET_NAME/test.txt
    
    aws s3 ls --profile r2 --endpoint-url=https://YOUR_CF_ACCOUNT_ID.r2.cloudflarestorage.com s3://YOUR_R2_BUCKET_NAME
    2022-05-13 18:34:20          2 test.txt