Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mongoexpuser/cloudflare-r2-bucket-with-aws-sdk-js-v3
Create, Configure, List and Delete R2 Bucket
https://github.com/mongoexpuser/cloudflare-r2-bucket-with-aws-sdk-js-v3
aws-sdk aws-sdk-js-v3 bucket cloudflare configure create delete list nodejs r2
Last synced: 24 days ago
JSON representation
Create, Configure, List and Delete R2 Bucket
- Host: GitHub
- URL: https://github.com/mongoexpuser/cloudflare-r2-bucket-with-aws-sdk-js-v3
- Owner: MongoExpUser
- License: mit
- Created: 2024-04-09T23:12:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-10T18:03:50.000Z (9 months ago)
- Last Synced: 2024-04-11T03:18:27.863Z (9 months ago)
- Topics: aws-sdk, aws-sdk-js-v3, bucket, cloudflare, configure, create, delete, list, nodejs, r2
- Language: JavaScript
- Homepage:
- Size: 381 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Cloudflare-R2-Bucket-With-AWS-SDK-JS-V3
Create/Deploy, Configure, List and Delete Cloudflare R2 Bucket (Object Storage) with AWS SDK for JavaScript/NodeJS V3.
The script can execute the followings:1) Create/deploy R2 buckets specified in the JSON input file.
2) Put/Add Lifecycle Configuration to the R2 buckets.
3) List all R2 buckets.4) Delete specified R2 buckets.
### Diagram Depicting R2 Bucket Information and Settings on Cloudflare R2 Console.
![Image description](https://github.com/MongoExpUser/Cloudflare-R2-Bucket-With-AWS-SDK-JS-V3/blob/main/clf-r2.png)## PURPOSE
* Normally, R2 bucket can be create/deployed, configured, listed and deleted on the Cloudflare console or via Cloudflare CLI (Wrangler).
* R2 bucket can also be deployed via AWS SDK in any language of choice, especially for those who:
1) Are already familiar with AWS SDK and
2) Want to create, configure, list and delete large number of buckets programatically.
* This repository contains code for creating/deploying, configuring, listing and deleting cloudflare R2 bucket (object storage) via AWS SDK for JavaScript/NodeJS V3, from any computer.
* AWS SDK for JavaScript/NodeJS V3 is clean, light weight, fast and it fully supports async-await syntax.* Also, cloudflare R2 bucket has lower storage cost with no egress fee, which makes it attractive to developers for storage.
## RUNNING the NodeJS script### To run the script, follow these steps:
1) #### Install NodeJS and @aws-sdk/client-s3 (v3) module, assuming Ubuntu OS and NodeJS v21.x
* sudo apt-get -y update
* sudo apt-get install -y ca-certificates curl gnupg
* sudo mkdir -p /etc/apt/keyrings
* curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
* echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_21.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
* sudo apt-get -y update
* sudo apt-get install -y nodejs
2) #### Download or clone the following files, from this repo, into the current working directory (CWD):
* NodeJS script: index.js
* JSON file: config.json3) #### Fill in relevant values in config.json file.
* References for config.json :4) #### Then run the code, assuming sudo access:
* sudo node index.js# License
Copyright © 2024. MongoExpUser
Licensed under the MIT license.