Skip to main content

Bucket

A Bucket is an object store. S3-compatible API on both targets — your code uses @aws-sdk/client-s3 against either, transparently.

Quick example

import { Project, Bucket } from '@sprintsail/sdk';

export const app = new Project('orders');

export const receipts = new Bucket(app, 'receipts', {
publicRead: false,
versioning: true,
});

Usage:

import { receipts } from '../infra.js';

const body = Buffer.from('order receipt content', 'utf8');
await receipts.put(`${orderId}.txt`, body);

const got = await receipts.get(`${orderId}.txt`);
if (got) console.log(got.toString('utf8'));

Config

interface BucketConfig {
publicRead?: boolean; // default false
versioning?: boolean; // default false
}

Target mapping

TargetMaps toNotes
awsS3Default private (full PublicAccessBlock). Versioning per config.
sprintsail-runtimeMinIOStandalone (kind dev) or HA. http://minio.minio.svc.cluster.local:9000 from inside the cluster.

Runtime methods

bucket.put(key: string, body: Buffer | string): Promise<void>;
bucket.get(key: string): Promise<Buffer | null>;

get returns null if the key doesn't exist. put overwrites.

What sail migrate does

Bucket migration copies every object from source to destination.

  • AWS → AWS uses S3's server-side CopyObject (no traffic through your machine).
  • Runtime → Runtime uses the S3 SDK against MinIO endpoints in both clusters.
  • AWS → Runtime and Runtime → AWS are planned in v1.1.

Safety

sail destroy refuses to delete a non-empty bucket. Empty it first (or use the cloud console / mc rb --force) and re-run destroy. This guard is deliberate — bucket data is the most expensive thing to lose accidentally.