Skip to main content
To connect a bucket for storing data from the sandbox, we will use the FUSE file system to mount the bucket to the sandbox. You will need to create a custom sandbox template with the FUSE file system installed. The guide for building a custom sandbox template can be found here.

Google Cloud Storage

Prerequisites

To use Google Cloud Storage, you’ll need a bucket and a service account. You can create a service account here and a bucket here. If you want to write to the bucket, make sure the service account has the Storage Object User role for this bucket. You can find a guide on creating a service account key here.

Mounting the bucket

To use the Google Cloud Storage we need to install the gcsfuse package. There’s simple template that can be used to create a container with the gcsfuse installed.
The bucket is mounted during the sandbox runtime using the gcsfuse command.

Flags

The complete list of flags is available here.

Allow the default user to access the files

To allow the default user to access the files, we can use the following flags:

Amazon S3

To use Amazon S3, we can use the s3fs package. The template setup is similar to that of Google Cloud Storage.
Similar to Google Cloud Storage, the bucket is mounted during the runtime of the sandbox. The s3fs command is used to mount the bucket to the sandbox.

Flags

The complete list of flags is available here.

Allow the default user to access the files

To allow the default user to access the files, add the following flag:

Cloudflare R2

For Cloudflare R2, we can use a setup very similar to S3. The template remains the same as for S3. However, the mounting differs slightly; we need to specify the endpoint for R2.

Flags

It’s the same as for S3.

Azure Blob Storage

Prerequisites

To use Azure Blob Storage, you’ll need a storage account and a container. The container must exist before you mount it. You can authenticate with the storage account access key or with a shared access signature (SAS) token for the container. Give the SAS token read and list permissions, plus write permission if you want to write files. Without list permission the mount fails.

Mounting the container

To mount the container, install Microsoft’s blobfuse2 package from the Microsoft package repository in a template.
blobfuse2 reads its settings from a config file. Replace the placeholders with your storage account name, container name and access key.
blobfuse2.yaml
mem-size-mb is the memory blobfuse2 reserves for its block cache. Keep it below the sandbox’s memory. It must be at least prefetch times block-size-mb (176 MB here), or the mount fails. prefetch is set explicitly because its default grows with the number of vCPUs. disk-size-mb caps the disk space the block cache may use under path. The container is mounted during the sandbox runtime using the blobfuse2 mount command.
To unmount the container, run sudo blobfuse2 unmount /home/user/bucket.

Authenticate with a SAS token

To use a SAS token instead of the access key, replace the mode and account-key lines in the config file with:

Options

For the full list of config options, see advancedConfig.yaml in the azure-storage-fuse repository.

Allow the default user to access the files

The container is mounted with sudo, so only root can access it by default. The allow-other: true line in the config file lets the default user read and write the files.