saarthdeshpande / serverless-cloud-storage

A self-hosted serverless cloud storage platform to host your own cloud storage at solely S3 rates, i.e., 50 TB /month at 1.6 INR/GB (~0.021 USD) per month.
MIT License
11 stars 2 forks source link
cloud-storage cost-effective s3 secure self-hosted serverless

Self-Hosted Serverless Cloud Storage

Host your own cloud storage at solely S3 rates, i.e., 50 TB /month at 1.6 INR/GB (~0.021 USD) per month.

Features

How to Set Up

Recommended IAM Policy:

Only allow public access to buckets and objects granted through new access control lists (ACLs)
{
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow all kind of http requests originating from https://<YOUR_WEBSITE>",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::<BUCKET_NAME>/*",
                "arn:aws:s3:::<BUCKET_NAME>"
            ],
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "https://<YOUR_WEBSITE>"
                    ]
                }
            }
        }
    ]
}

Sync with a Local Folder



* Replace the value for `LOCAL_FOLDER` with the folder you want to sync your S3 bucket with.
* To keep this script always running in the background, run `crontab -e` and add the line: `@reboot local-to-s3.sh`.

**NOTE**: This will only sync your local changes to the S3 bucket. 

* To sync S3 bucket changes to your local folder, run `crontab -e` and add the line: `*/30 * * * * aws s3 sync s3://<BUCKET_NAME> <abs-path-to-your-local-folder> --delete >> ~/logs/s3-to-local/log.$(date +%B%Y)`.
* This last sync isn't ideal and may lead to temporarily inconsistent data across the local folder and S3 bucket. Open to suggestions!