Docs

Storage

Storage is an object storage bucket in the customer's cloud for your code: files, uploads, reports, exports, and backups up to 5 TB per object. One API reads and writes objects by key (a path such as reports/2026-10.json) on S3, Cloud Storage, Blob Storage, or a local directory.

alien.ts
import * as alien from "@alienplatform/core"

const files = new alien.Storage("files")
  .versioning(true)
  .lifecycleRules([{ days: 30, prefix: "tmp/" }])
  .build()

const api = new alien.Worker("api")
  .code({ type: "source", src: "./api", toolchain: { type: "typescript" } })
  .link(files)
  .permissions("execution")
  .build()

export default new alien.Stack("acme")
  .add(files, "frozen")
  .add(api, "live")
  .permissions({
    profiles: { execution: { files: ["storage/data-read", "storage/data-write"] } },
  })
  .build()

In this stack:

  • .link(files) connects the bucket to the api Worker, the workload (the running code) that uses it. Alien injects the bucket's connection details, its binding, into the Worker, read by the SDK client.
  • The execution permission profile, the named set of cloud permissions a workload runs with, grants storage/data-read and storage/data-write.
  • "frozen" means the customer's admin creates the bucket during initial setup. "live" resources, like the Worker, are created and updated by Alien on every release. See Frozen and live.

The api Worker writes and reads objects by key:

api/src/files.ts
import { storage } from "@alienplatform/sdk"

const files = storage("files")
await files.put("reports/2026-10.json", Buffer.from(JSON.stringify({ ok: true })))
const { data } = await files.get("reports/2026-10.json")

Platforms

files becomes a bucket in the customer's cloud:

PlatformBacking serviceCreated by
AWSAmazon S3 bucketAlien
GCPCloud Storage bucketAlien
AzureBlob container in the stack's storage accountAlien
KubernetesS3, an S3-compatible store such as MinIO, Cloud Storage, or Blob StorageThe customer, through an external binding
MachinesSame services as KubernetesThe customer, through an external binding. The resource must be "frozen". See Machines.
LocalDirectory under .alien/Alien
  • Kubernetes: Alien doesn't create a bucket. The build fails unless each Storage resource has an external binding of type storage. Guarantees then depend on the service the customer points it at.
  • Azure: every Storage resource in a stack is a container inside one storage account (Standard, LRS, Hot tier) that Alien adds to the stack.

Frozen or live

Storage can be "frozen" (created once during initial setup by the customer's admin) or "live" (created and updated by Alien on releases). With an encryption key it must be "frozen". See Frozen and live.

The resource ID becomes part of the bucket name (<prefix>-<id>). It must be lowercase letters, digits, and hyphens, and at most 54 characters.

Alternatives

Storage isn't a database. For small values looked up by key, with TTL and compare-and-swap, use KV. For relational data, use Postgres.

Options

MethodTypeDefaultNotes
.publicRead(on)booleanfalseAnonymous read access to every object.
.versioning(on)booleanfalseKeeps prior versions of overwritten and deleted objects. See Azure for limits.
.lifecycleRules(rules){ days: number, prefix?: string }[][]Deletes objects older than days, optionally only under prefix. Validated per cloud at build time. See Lifecycle rules.
.corsAllowedOrigins(origins)string[][]Browser origins allowed to GET and HEAD objects through signed URLs. See CORS.
.corsUploadOrigins(origins)string[][]Browser origins allowed to PUT objects through signed upload URLs. See CORS.
.encryptionKey(key)Keyprovider-managed keyEncrypts objects with a customer-managed Key. Storage and Key must both be "frozen". Can't change after the bucket exists.
.notify(queue, rule?)Queue, { prefix?, suffix?, events? }nonePuts an event into a Queue for each new object that matches. Call it once per rule. See Notify a queue.
.enabled(input)boolean stack inputalways onCreates the resource only when the input is true.

The ID and the encryption key are fixed once the bucket exists. Other options can change on a later release.

Use it from code

Get a handle with storage(name). The name is the resource ID from alien.ts. Creating the handle does no I/O; the binding resolves on the first call.

src/files.ts
import { storage } from "@alienplatform/sdk"

const files = storage("files")

await files.put("reports/2026-10.json", Buffer.from(JSON.stringify({ ok: true })), {
  attributes: { contentType: "application/json" },
})

const { data, meta, attributes } = await files.get("reports/2026-10.json")
const report = JSON.parse(data.toString("utf8"))

for (const object of await files.list("reports/")) {
  console.log(object.location, object.size)
}

The full method list is in the API reference.

Common patterns

Signed URLs

A browser or another service uploads or downloads an object directly. The bytes don't pass through your code.

const upload = await files.signedUrl({ method: "PUT", path: "uploads/avatar.png", expiresIn: 900 })

// Send upload.url, upload.method and upload.headers to the client.
await fetch(upload.url, { method: upload.method, headers: upload.headers, body: imageBytes })

The result is a full request, not a bare URL. Send the returned headers with it. For a browser to read objects through signed GET URLs from another origin, set .corsAllowedOrigins(). For a browser to upload through signed PUT URLs, set .corsUploadOrigins().

Write once

condition: "absent" writes only when nothing exists at the path. If two callers race, exactly one succeeds; the other gets STORAGE_OBJECT_ALREADY_EXISTS.

Use it for idempotent outputs and basic locks:

import { AlienError } from "@alienplatform/sdk"

try {
  await files.put(`exports/${jobId}.csv`, csv, { condition: "absent" })
} catch (error) {
  if (!(error instanceof AlienError) || error.code !== "STORAGE_OBJECT_ALREADY_EXISTS") throw error
  // Another run already wrote this export.
}

React to new objects

A Worker can run when objects are created or deleted. Declare the trigger in alien.ts and register a handler:

alien.ts
const uploads = new alien.Storage("uploads").build()

const processor = new alien.Worker("processor")
  .code({ type: "source", src: "./processor", toolchain: { type: "typescript" } })
  .trigger({ type: "storage", storage: uploads.ref(), events: ["created"] })
  .build()
processor/src/index.ts
import { onStorageEvent, storage } from "@alienplatform/sdk"

const uploads = storage("uploads")

onStorageEvent("uploads", async event => {
  const { data } = await uploads.get(event.objectKey)
  // ...
}, { prefix: "incoming/" })

Delivery is at least once, so make handlers idempotent. Per-cloud wiring is in Behavior and limits.

Notify a queue

A Storage can put an event into a Queue every time an object is created or overwritten. Each .notify() call adds a rule:

alien.ts
const work = new alien.Queue("work").build()

const objects = new alien.Storage("objects")
  .notify(work, { prefix: "uploads/", suffix: ".json" })
  .notify(work, { prefix: "uploads/", suffix: ".csv" })
  .build()

const ingest = new alien.Worker("ingest")
  .code({ type: "source", src: "./ingest", toolchain: { type: "typescript" } })
  .link(objects)
  .trigger({ type: "queue", queue: work.ref(), batch: { maxMessages: 10, maxWindowSeconds: 5 } })
  .permissions("execution")
  .build()

Consume the queue like any other: a Worker queue trigger, single or batched, or a receive() loop. storageEventFromMessage reads the event from a message:

ingest/src/index.ts
import { onQueueMessage, storage, storageEventFromMessage } from "@alienplatform/sdk"

onQueueMessage("work", async message => {
  const event = await storageEventFromMessage(message)
  const { data } = await storage("objects").get(event.objectKey)
  // ...
})

The event carries the bucket and key, so read the object itself. Delivery is at least once and unordered.

Choose notifications over a storage trigger when you want batches, a suffix filter, or a consumer that pulls with receive(). A storage trigger also handles deleted events. A Storage can't do both: one with notifications can't be a Worker's storage trigger source.

Rules, limits, frozen and live buckets, and per-cloud delivery are in Notifications.

Read from your hosted software

To read or write a customer's bucket from your own backend, publish it as a remote binding. Remote storage supports get, put, delete, list, and head.

For a hosted product that keeps each customer's files in a bucket in their cloud, without a deployment, see Customer buckets.

Permissions

Grant a permission set in the workload's profile, naming the resource:

SetGrants
storage/data-readGet, head, and list objects.
storage/data-writeRead and write objects, including put, delete, and copy.
storage/remote-data-writeObject operations on this one bucket from your hosted software through a remote binding.
storage/trigger-managementAttaching and removing event notification wiring for Worker storage triggers, and for notifications on a live Azure Storage.
storage/provision, storage/management, storage/heartbeatUsed by initial setup and by Alien's management identity.
key/native-storageUsing the customer-managed Key the bucket is encrypted with.

When a workload's profile doesn't name the bucket, .link() and a storage trigger grant storage/data-write. Naming the bucket in the profile replaces that default. See Permissions.

Next

On this page