DEV Community

Jaskirat Randhawa for Fastly

Posted on

5

Private, cost-effective cloud storage that you will want to use!

If you are like me who wants private, affordable and easy to use storage, then Fastly Object Storage might be for you. It is an S3 compatible object storage with zero egress fees! Let’s take a look at how you can set it up and use S3 compatible tools to interact with your data. In this demo, I’ll walk you through connecting one of the popular tools SFTPGo, with Fastly Object Storage.

Prerequisites

This demo assumes that you have

  1. A Fastly account with Fastly Object storage
  2. A Fastly API Token set locally as $FASTLY_API_TOKEN
  3. AWS CLI and Docker installed locally on your machine

Fastly Object Storage product page

Creating an Object Storage Key and a Bucket

Once you have the object storage available in your account, create an access key in the Fastly web interface. It consists of an access key ID and a secret key that is used to authenticate requests made to the Fastly Object Storage.

  1. Log in to the Fastly web interface.
  2. Navigate to Resources > Object Storage.
  3. Click Create Key.
  4. Enter a description and select the scope of access (Note: I am using read-write-admin for this demo.)
  5. Note the access key and secret key, as the secret key will not be visible again.

Alternatively, if you have a Fastly API token, you can use curl to create an access key for object storage.

export FASTLY_API_TOKEN=xxxxx

# Create an access key using Fastly API token.
# It will create AWS_ACCESS_KEY and AWS_SECRET_KEY set of keys
curl \
-H "Fastly-Key: $FASTLY_API_TOKEN" \
-H "Content-Type: application/json" \
-X POST https://api.fastly.com/resources/object-storage/access-keys \
-d '{
  "description": "Demo access key",
  "permission": "read-write-admin",
  "buckets": ["sftpgo-bucket"]
}'
Enter fullscreen mode Exit fullscreen mode

Configure AWS CLI and create a new Fastly profile nano ~/.aws/config. You can pick one of three available regions: us-west, us-east, or eu-central.

[default]
region = us-west

[profile fastly]
region = us-west
endpoint_url = https://us-west.object.fastlystorage.app
Enter fullscreen mode Exit fullscreen mode

Here are some commands to configure the AWS CLI to work with Fastly Object Storage. Let’s create a bucket sftpgo-bucket that we will connect our SFTPGo client to in the next steps. Feel free to play around with using AWS CLI to interact with Fastly Object Storage. We will be able to see all the contents stored in the bucket using the SFTPGo client.

# Configure the AWS CLI
aws configure --profile fastly

# Create a bucket
aws s3 mb s3://sftpgo-bucket --profile fastly

# List buckets
aws s3 ls --profile fastly

# Upload a file
aws s3 cp ./sample.txt s3://sftpgo-bucket/ --profile fastly

# List contents of a bucket
aws s3 ls sftpgo-bucket --profile fastly
Enter fullscreen mode Exit fullscreen mode

Using SFTPGo is as easy as 1-2-3

What is SFTPGo?

SFTPGo is one of my favorite file management solutions that supports S3 as a backend. One of the best things about it is that you can store and share files with your personal contacts or work colleagues with a convenient link sharing function. Advanced users can also find comfort in its abilities to create and manage users, folders, mounts and other resources. You can also go a step further to set up two-factor authentication.

We’ll keep it simple. All you have to do is:

  1. Install SFTPGo
  2. Add Fastly Object Storage as a backend
  3. Done! You have a working setup.

There are multiple ways to install SFTPGo. I’m going to use docker-compose with minimal configuration. It’ll take less than 2 minutes to get up and running.

version: "3.8"
services:
  sftpgo:
    image: drakkan/sftpgo:latest
    container_name: some-sftpgo
    ports:
      - "8080:8080"
      - "2022:2022"
    volumes:
      - sftpgodata:/srv/sftpgo
      - sftpgohome:/var/lib/sftpgo
    restart: unless-stopped
volumes:
  sftpgodata:
  sftpgohome:
Enter fullscreen mode Exit fullscreen mode

Create a docker-compose.yaml file and run docker-compose up -d to spin your service.

This will create a barebones SFTPGo server for you. You have plenty of customization options depending on your needs. Next, launch 127.0.0.1:8080/web/admin/login and run through the first time setup for the administrator. Provide the username and password that you’ll use to manage this instance. Note: Don’t worry if you lose these credentials or docker volume. Your data will still remain safe in Fastly Object Storage, because we’re using it as a backend.

SFTPGo admin login

The wonderful thing about this sort of a setup is that you can host your content without needing a degree in server management. It’s essentially your very own digital attic. You get to control everything. Now, you’re thinking, "Wait, I don’t want to mess around with code and stuff. I just want to store some content." No problem. Setting up Fastly Object Storage with SFTPGo is quite simple. You’re not building a spaceship here—just a safe space for your assets.

Here’s the breakdown:

Create a new user account

Once you log into the WebAdmin console, go to Users and click on Add to create a new user account. This is the simplest way to get started. You can, of course, do more than that like creating groups and virtual folders.

SFTPGo user management

Configure the user account with following settings:

  • Storage: S3 (Compatible)
  • Bucket: Your bucket name
  • Region: us-west
  • Access Key: Generated earlier using Fastly API
  • Access Secret: Generated earlier using Fastly API
  • Endpoint: https://us-west.object.fastlystorage.app
  • Toggle on the option for Use path-style addressing

SFTPGo user configuration

Done. Now test your setup

Go to 127.0.0.1:8080/web/client/login and log in with the credentials of the user that you just created. You should be able to see the contents of your storage bucket. Violá! You can now use the UI to upload, download and share your files.

SFTPGo web client

To share files, click on options for a file or a folder. Then click on Share. It will prompt you with a few options to create a Share.

SFTPGo add share

Once you’ve created a Share, you can go to Share in the left sidebar and get the options for viewing and managing your shares. Select the one you created and it’ll provide you a few links that you can pass along to others.

SFTPGo share links

Easy to use storage that’s more private than your secret snack stash

So, there you have it: a private cloud storage that’s simple to set up, easy to share with your friends and colleagues (okay, family too). Once you set up the SFTPGo instance, you don’t need to manage any code. The best part? Using Fastly Object storage, you only pay for what you actually use.

Tell us how are you’re using Fastly Object Storage

I’m a product manager at Fastly and I would like to hear more about how you are using Fastly Object Storage for your personal or work life. What tools are you using? What tools would you like us to support? Join the conversation in our forum, and get started for free.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs