Ployter

Buckets (S3 and Spaces)

How to create an S3 or Spaces bucket in your cloud, use it in services through variables, manage files from the panel and set up public read and automatic cleanup.

A bucket stores files outside the servers: user uploads, site images, exports and container database backups. Ployter creates the bucket in your account (S3 on AWS, Spaces on DigitalOcean), along with a key that can only see that bucket, and hands everything to services through variables.

Use a bucket whenever the service has replicas: a service with replicas doesn't use volumes.

Before you start

  • Connect AWS or DigitalOcean.
  • Buckets count toward the plan's Managed databases, caches and buckets limit.
  • Your role needs the Create managed databases and caches permission.

Create a bucket

  1. Open the project and click Database or bucket.
  2. In Type, pick Bucket.
  3. Fill in the Name (e.g. Arquivos) and pick the Account.
  4. Pick the Region. On DigitalOcean, only regions with Spaces show up.
  5. Turn on Public read if files should open through a direct link (images and site files). When it's off, files only open through a signed URL generated by the application. You can change this later.
  6. Turn on Versioning if you want to keep previous versions of each file (overwritten or deleted by mistake). The cloud charges for the space versions take.
  7. Click Create bucket.

Managed resource modal with the Bucket type selected
Managed resource modal with the Bucket type selected

The bucket is ready in seconds.

  • AWS: the panel creates an IAM user that can only access this bucket.
  • DigitalOcean: the panel creates a Spaces key that can only access this bucket.

Use it in services

Services use the bucket by reference, like databases. In a service variable, type ${{ and pick the bucket. The value is built at deploy time and follows key changes.

Variable What it is
S3_BUCKET Bucket name in the cloud
S3_REGION Region (on DigitalOcean, always us-east-1, the signing region)
S3_ENDPOINT S3 API address (on DigitalOcean, the region's Spaces address)
S3_PUBLIC_URL Public address of the files, only with Public read on
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION The bucket key, under the names AWS SDKs read automatically
AWS_ENDPOINT_URL_S3 DigitalOcean only: makes the SDKs go to Spaces

Example in the api service, with a bucket named arquivos:

S3_BUCKET=${{arquivos.S3_BUCKET}}
S3_ENDPOINT=${{arquivos.S3_ENDPOINT}}
AWS_ACCESS_KEY_ID=${{arquivos.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY=${{arquivos.AWS_SECRET_ACCESS_KEY}}
AWS_REGION=${{arquivos.AWS_REGION}}

Spaces uses the S3 API: S3Client, boto3 and aws-cli work when pointed at S3_ENDPOINT.

In the bucket's Overview, the Access card shows the access details: the bucket, region, key and secret key (with Show). People without the View password and connection details permission don't see the secret key, but services get everything through variables.

Manage files

The Files section is a file manager for the bucket. It requires the Manage bucket files permission.

Files section of a bucket with folders and files
Files section of a bucket with folders and files

  • Upload files and Upload folder, or drag onto the screen. Each file goes straight to the bucket, up to 5 GB.
  • New folder and New file (opens empty in the editor; the file is only created when you save).
  • Select items to Download, Move to..., Copy to... or Delete.
  • In each file's menu: Open, Edit, Rename, Copy link and Details.

With Copy link, the panel shows the public address (if the bucket has public read) or generates a signed link valid for 1 hour, 1 day or 7 days (maximum). Generating a new bucket key invalidates signed links.

In Details, you change the file's Type (Content-Type) and Cache (Cache-Control).

Warning

The backups/ folder holds the automatic backups of container databases. Deleting or moving files in it removes the backup from the service's list. See Backups and restore.

Settings

In the Settings section:

  • Name in the panel: changes only the name shown in Ployter. The bucket name in the cloud doesn't change.
  • Public read: takes effect immediately. When on, S3_PUBLIC_URL becomes available in the variables (on the next deploy of the services using it).
  • Deletion protection: the panel refuses to delete the bucket while it's on.

Automatic cleanup

Automatic cleanup deletes the files in a folder by itself after N days. Use it for temporary folders and logs.

  1. In Automatic cleanup, click Rule.
  2. Enter the folder (e.g. tmp/) and the days (e.g. 7).
  3. Click Save cleanup.

The provider checks once a day. Abandoned multipart uploads are removed after 7 days.

Warning

A rule without a folder applies to the whole bucket, including the backups/ folder.

Metrics

On AWS, the Metrics and alerts section shows the size and number of files (including previous versions), measured by AWS once a day. The first measurement comes up to 48 hours after the bucket is created. DigitalOcean doesn't provide these metrics through its API.

Replace the key

If the key leaked:

  1. Click More actions → Generate new key and confirm with Generate.
  2. Deploy the services that use the bucket.

The current key is deleted immediately: services lose access until the deploy.

Delete

Click More actions → Delete. Every file in the bucket is deleted, including previous versions and any backups stored in it. It can't be recovered.