Skip to content

Your own bucket

A disk can keep its files in a bucket you own instead of Archil’s. Archil still keeps the data in use in its storage layer, and copies writes to your bucket in the background, where they’re ordinary objects any S3 tool can read without Archil. Destroying the disk leaves them there. Archil offers it on its paid plans.

On S3, the bucket’s policy trusts Archil’s IAM role for your region, only on behalf of disks in your organization, so no access key exists anywhere.

AWS accountArchil's roleDatasetdisk · org acmeStoreS3 Bucket · datasets/notesdisk · another org
The bucket policy lets Archil's role in only for disks in your organization. A disk in another organization, using the same role, is refused.

ArchilAWS.S3Disk declares the bucket policy and the disk together:

src/storage.ts
import * as AWS from "@alchemy.run/aws";
import * as ArchilAWS from "@alchemy.run/archil/AWS";
export const Store = AWS.S3.Bucket("Store", {});
export const Dataset = ArchilAWS.S3Disk("Dataset", { bucket: Store, prefix: "datasets/" });

The disk’s files land under datasets/ in Store. Your Stack needs AWS.providers() next to Archil.providers().

The policy is scoped to your Archil organization, so Alchemy needs its id. Enter it in your profile:

Terminal window
alchemy profile edit --add Archil

Or set ARCHIL_ORGANIZATION in CI. Find the id in the console.

R2, Google Cloud Storage, Azure Blob and other S3-compatible stores take keys. Give them in storage on Archil.Disk:

src/storage.ts
export const Dataset = Archil.Disk("Dataset", {
storage: {
type: "r2",
bucketName: "datasets",
bucketEndpoint: "https://<account>.r2.cloudflarestorage.com",
accessKeyId: Config.Redacted("R2_ACCESS_KEY_ID"),
secretAccessKey: Config.Redacted("R2_SECRET_ACCESS_KEY"),
},
});

Changing storage replaces the disk.

Archil writes to the bucket after the write is durable in its own storage, so a tool reading the bucket directly sees a new file a little later than a client of the disk does. Read through the disk when you need the latest write.