Skip to content
betterstack-alchemyUnofficial

Cloud.ObjectCacheBucket

Kind ResourceType id BetterStack.Cloud.ObjectCacheBucketSource src/Cloud/ObjectCacheBucket.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_CLOUD_BILLABLE=1 because it bills; live runs need the owner's go-ahead (test/Cloud/ObjectCacheBucket.test.ts).

A bucket a Better Stack Cloud ObjectCache serves. Clients address it by name (defaults to originBucket); its origin is a bucket on your own S3-compatible storage.

name, originBucket, originEndpoint, originPrefix and objectProxyId replace the bucket. The origin keys, originRegion and originForcePathStyle change in place. The keys are write-only: the API stores them encrypted and never returns them, so they are compared with the previous deploy, never with the API, and never cause a perpetual diff. Buckets are free; they go away with their object cache.

Connecting. A bucket can have S3 keys of its own that sign requests for this bucket only (scopedCredentials): then accessKeyId, secretAccessKey (Redacted), endpointUrls and endpoint carry them. A new bucket has none (the API answers no_credentials; the attributes stay undefined, and clients use the cache’s keys): set rotateCredentials to create them, and to a new value later to rotate them once (the previous keys keep working for a day). Keys created or rotated in the console or CLI are read on the next deploy.

Zone. A child doesn’t take its zone from its parent: it uses its own availabilityZone, else the credentials’ zone. When the parent lives in another zone, pass the parent’s along (availabilityZone: parent.availabilityZone), or every call for it answers NotFound.

Serve a second bucket from an existing cache

yield* BetterStack.Cloud.ObjectCacheBucket("media", {
objectProxyId: cache.id,
originEndpoint: "https://s3.us-west-2.amazonaws.com",
originBucket: "my-media",
originRegion: "us-west-2",
originAccessKeyId: Redacted.make(process.env.AWS_ACCESS_KEY_ID!),
originSecretAccessKey: Redacted.make(process.env.AWS_SECRET_ACCESS_KEY!),
});

Serve one folder of a bucket under its own name

yield* BetterStack.Cloud.ObjectCacheBucket("tenant-a", {
objectProxyId: cache.id,
name: "tenant-a",
originEndpoint: "https://s3.us-west-2.amazonaws.com",
originBucket: "my-media",
originPrefix: "tenant-a/",
originAccessKeyId: Redacted.make(process.env.AWS_ACCESS_KEY_ID!),
originSecretAccessKey: Redacted.make(process.env.AWS_SECRET_ACCESS_KEY!),
});

By object cache and id

const existing = BetterStack.Cloud.ObjectCacheBucket.lookup({ objectProxyId: "42", id: "7" });

objectProxyId string required

The object cache that serves the bucket (cache.id; the API calls an object cache an "object proxy"). Changing it replaces the bucket.

originAccessKeyId Redacted<string> required

The access key ID for the origin bucket. Stored encrypted and never returned, so a change is detected against the previous deploy's value only (rotating it in the storage provider's console is not seen). Changes in place.

originBucket string required

The name of the bucket at the origin, at most 255 characters. Can't be changed after the bucket is added.

originEndpoint string required

The HTTPS URL of the origin's storage service, such as https://s3.us-east-1.amazonaws.com. Must use a hostname, not an IP address, and have no credentials, path, query or fragment. Can't be changed after the bucket is added.

originSecretAccessKey Redacted<string> required

The secret key for the origin bucket. Same rules as originAccessKeyId. Changes in place.

availabilityZone string

Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.

name string

The bucket name clients use with the object cache, 3-63 lowercase letters, digits, dots and hyphens, starting and ending with a letter or digit. Must be unique in the object cache. Defaults to origin_bucket. Can't be changed after the bucket is added.

originForcePathStyle boolean

Whether we send the bucket name in the URL path to the origin, instead of in the hostname. Defaults to true.

originPrefix string

A folder in the bucket at the origin to serve as the whole bucket, such as tenant-a/. Clients see only the objects under it. Leave it out to serve the whole bucket. Can't be changed after the bucket is added.

originRegion string

The origin's region, such as us-east-1 or auto. Defaults to us-east-1.

rotateCredentials string

Rotate the credentials: every change of this value after create (for example a date, "2026-12") calls the API's rotate operation once on the next deploy, and the new secrets replace the old ones in the attributes (and so in every env that references them). Leaving it out, or keeping the same value, never rotates. A rotation done in the console or CLI is simply read on the next deploy.

accessKeyId Redacted<string> always set

The S3 access key ID (credentials access_key_id).

availabilityZone string always set

Availability zone the resource lives in, such as us-west-2a.

endpoint string always set

The endpoint to give an S3 client: the HTTPS one when there is one, else the first.

endpointUrls string[] always set

The S3 endpoint URLs: an HTTP URL in each attached network, plus the public HTTPS URL with publicAccess (credentials endpoints).

id string always set

The bucket's ID.

objectProxyId string always set

The object cache that serves the bucket.

previousAccessKeyId string always set

After a rotation: the previous access key ID, still valid until rotatingUntil.

rotatingUntil string always set

After a rotation: until when the previous keys keep working.

secretAccessKey Redacted<string> always set

The S3 secret access key (credentials secret_access_key).

createdAt string

When the bucket was added.

name string

The bucket name clients use with the object cache, 3-63 lowercase letters, digits, dots and hyphens, starting and ending with a letter or digit. Must be unique in the object cache. Defaults to origin_bucket. Can't be changed after the bucket is added.

originBucket string

The name of the bucket at the origin, at most 255 characters. Can't be changed after the bucket is added.

originCreationDate string | null

When the bucket at the origin was created, as the origin reports it.

originEndpoint string

The HTTPS URL of the origin's storage service, such as https://s3.us-east-1.amazonaws.com. Must use a hostname, not an IP address, and have no credentials, path, query or fragment. Can't be changed after the bucket is added.

originForcePathStyle boolean

Whether we send the bucket name in the URL path to the origin, instead of in the hostname. Defaults to true.

originPrefix string

A folder in the bucket at the origin to serve as the whole bucket, such as tenant-a/. Clients see only the objects under it. Leave it out to serve the whole bucket. Can't be changed after the bucket is added.

originRegion string

The origin's region, such as us-east-1 or auto. Defaults to us-east-1.

scopedCredentials boolean

Whether the bucket has its own access keys. When it's false, rotate the bucket's keys to create them.

ObjectCacheBucket.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

id string required

The bucket's ID.

objectProxyId string required

The object cache that serves the bucket.

availabilityZone string

Zone the object cache lives in. Defaults to the credentials' zone.