Skip to main content
An instance’s disk belongs to that one instance. For files that several instances share, or that should outlive any of them, mount a bucket you own as a folder. Whatever the instance writes there lands in the bucket, and the next instance that mounts it sees the same files. It works with Amazon S3 and any S3-compatible store, such as Cloudflare R2. A mount needs a VM instance. On a default instance, copy files instead.

Mount a bucket

Create a VM with the bucket’s region and keys in env:
Everything running in the instance can read those keys, so give them access to this bucket alone. For temporary credentials, add RCLONE_S3_SESSION_TOKEN. For a store other than Amazon S3, add RCLONE_S3_ENDPOINT and set RCLONE_S3_PROVIDER to the name rclone uses for it. Then install rclone and mount the bucket with one exec:
/mnt/bucket is now the bucket. Programs read and write it like any folder, as root or as the image’s own user, and they can overwrite, rename, and delete files, including formats that are rewritten in place such as DOCX and XLSX.

What to expect

  • Writes reach the bucket a few seconds later. A file starts uploading about five seconds after the program closes it. Give it time to finish before you unmount, stop, or delete the instance.
  • A mount is slower than the disk. Every file is a request to the bucket. Keep working files such as a build or node_modules on the instance’s disk, and use the bucket for what has to be shared or kept.
  • A restart drops the mount. It stays through sleep and wake. After a stop, restart, resize, or update, send the same exec again once the instance is running.
With a network allow list, add the bucket’s domain, for example *.amazonaws.com.

On a default instance

A default instance cannot mount a filesystem. With the same env, copy files between the bucket and the disk through exec instead: