Skip to content
betterstack-alchemyUnofficial

Cloud.Valkey

Kind ResourceType id BetterStack.Cloud.ValkeySource src/Cloud/Valkey.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/Valkey.test.ts).

A managed Valkey (Redis-compatible) instance on Better Stack Cloud, with one primary and up to two replicas. It bills from creation (monthly by default; term: "annual" commits a year).

The deploy blocks until the instance is running; a failed or degraded instance fails it with WaitFailed, and one still provisioning after 30 minutes with WaitTimeout (one that ends destroyed reads as gone, so its wait times out too). A running instance can still be adding a replica or opening its public TLS endpoint.

What outlives a destroy, and keeps billing. Snapshots outlive their database: removing the instance keeps every snapshot, the ones its ValkeyScheduledSnapshot took included, and they stay billed (“Database snapshots are billed like server snapshots”). This stack doesn’t track the scheduled ones (they carry no marker), so alchemy destroy and nuke leave them: remove them in Databases → Snapshots, or with the SDK’s listFlatValkeySnapshot / deleteFlatValkeySnapshot. A ValkeySnapshot of this stack is deleted with the stack.

What changes in place: name, term, metadata, evictionPolicy, persistence, publicAccess, replicaCount; type (a rescale) and engineVersion (an upgrade), each waited on until running again; networkIds and firewallIds (attach/detach). What replaces it: teamId and availabilityZone. A replacement that keeps an explicit name deletes the old instance first (names are unique among live instances). Removing evictionPolicy, persistence, publicAccess or replicaCount from the config keeps the current value.

Networking: plain connections on host:port from the Networks in networkIds; with publicAccess: true also TLS on publicHost:tlsPort. A Firewall in firewallIds filters what reaches it.

Connection details: host, port, publicHost and tlsPort come from the instance’s endpoint; user, authToken, connectionUri (valkey://, private, no TLS), tlsConnectionUri (valkeys://, public) and caCertificate from the credentials endpoint, read once the instance is running. Secrets are Redacted.

Credentials: the deploy never rotates them on its own. Set rotateCredentials to a new value to rotate the AUTH token once; a rotation done in the console or CLI is read on the next deploy, without a replace.

After delete the API keeps answering the instance with status: "destroyed" for a while; that reads as gone. Its snapshot schedules go with it.

A cache on a private network

const network = yield* BetterStack.Cloud.Network("private", {
ipPrefix: "10.0.0.0",
ipPrefixLength: 24,
});
const cache = yield* BetterStack.Cloud.Valkey("cache", {
type: "VK1",
persistence: "none",
evictionPolicy: "allkeys-lru",
networkIds: [network.id],
});

A Cloud.Service reading the URI from its environment

const cache = yield* BetterStack.Cloud.Valkey("cache", { type: "VK1" });
// In the Service's props: env: { REDIS_URL: cache.connectionUri }
// In its program: const url = yield* Config.Redacted("REDIS_URL");

The parts, for a Redis-compatible client

const env = {
VALKEY_HOST: cache.host,
VALKEY_PORT: cache.port,
VALKEY_USERNAME: cache.user,
VALKEY_PASSWORD: cache.authToken,
};

Reference an instance by id

const existing = BetterStack.Cloud.Valkey.lookup({ id: "42" });

Reference an instance by name (fails with AmbiguousLookup when several share it)

const byName = BetterStack.Cloud.Valkey.lookup({ name: "sessions" });

type string required

The plan, which sets the memory, such as VK1. List the plans with the SDK's listValkeyType (or betterstack valkey-type list). Changes in place: a rescale, waited on until the instance is running again on the new plan.

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.

engineVersion string

The Valkey version, such as 8.1. Defaults to the latest version. List them with the SDK's listValkeyVersion; availableEngineVersions on the attributes says which ones this instance can move to now. Changes in place: an upgrade, waited on until the instance is running on the new version.

evictionPolicy "noeviction" | "allkeys-lru" | "allkeys-lfu" | "allkeys-random" | "volatile-lru" | "volatile-lfu" | "volatile-random" | "volatile-ttl" | string

What Valkey does when memory is full, as its maxmemory-policy setting. - noeviction: Valkey refuses writes when memory is full. - allkeys-lru: Valkey evicts the least recently used keys. - allkeys-lfu: Valkey evicts the least frequently used keys. - allkeys-random: Valkey evicts random keys. - volatile-lru: Valkey evicts the least recently used keys that have an expiry. - volatile-lfu: Valkey evicts the least frequently used keys that have an expiry. - volatile-random: Valkey evicts random keys that have an expiry. - volatile-ttl: Valkey evicts the keys with an expiry that expire soonest.

firewallIds string[]

The ID of the [Firewall](/reference/cloud/firewall/) attached to the instance, at most one. Changes in place (the old one is detached before the new one is attached). Removing the prop keeps what is attached; [] detaches it.

metadata CreateValkeyRequestMetadataMap

Your own tags as string pairs, at most 10. An update replaces all tags. Set it to an empty object to remove every tag.

name string

The instance's name, up to 255 characters, unique among the team's live Valkey instances. Defaults to a unique name generated from the stack, stage and logical id. Changes in place.

networkIds string[]

The IDs of your [Network](/reference/cloud/network/)s attached to the instance; they must belong to its team. Changes in place (attach and detach actions). Removing the prop keeps what is attached; [] detaches all.

persistence "none" | "rdb" | string

Whether Valkey keeps the data across restarts. Snapshots work either way. - rdb: Valkey keeps the data across restarts. - none: Valkey keeps the data in memory only, as a pure cache.

publicAccess boolean

Whether the primary accepts connections with TLS on a public IP, on port 6380. The port opens shortly after the change.

replicaCount number

How many replicas the instance has besides the primary, from 0 to 2. We add or remove replicas shortly after the change.

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.

teamId string

Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.

term "monthly" | "annual"

The billing term: monthly (the default) or annual. annual commits you to paying for a whole year. A change applies at once and starts a new term.

authToken Redacted<string> always set

The AUTH token, Valkey's password (credentials auth_token).

availabilityZone string always set

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

caCertificate string always set

The CA certificate (PEM) for the public TLS endpoint, undefined while publicAccess is off.

connectionUri Redacted<string> always set

valkey:// URI for your private networks, without TLS, with the token in it (credentials uri).

host string always set

The hostname to connect to from your private networks (endpoint.hostname), without TLS. It follows the current primary.

id string always set

The instance's ID.

port number always set

The port without TLS on your private networks, 6379 (endpoint.port).

publicHost string always set

The hostname of the public TLS endpoint (endpoint.publicHostname), undefined while publicAccess is off.

rotatingUntil string always set

After a rotation: until when the previous token still works; undefined otherwise.

tlsConnectionUri Redacted<string> always set

valkeys:// URI for the public TLS endpoint, with the token in it; undefined while publicAccess is off (credentials tls_uri).

tlsPort number always set

The public TLS port, 6380 (endpoint.tlsPort), undefined while publicAccess is off.

user string always set

The username, always default (credentials user).

availableEngineVersions string[]

The versions you can upgrade the instance to now.

createdAt string

When the instance was created.

endpoint ValkeyEndpoint

Where to connect to the current primary.

engineVersion string

The Valkey version, such as 9.1.

evictionPolicy "noeviction" | "allkeys-lru" | "allkeys-lfu" | "allkeys-random" | "volatile-lru" | "volatile-lfu" | "volatile-random" | "volatile-ttl"

What Valkey does when memory is full, as its maxmemory-policy setting. - noeviction: Valkey refuses writes when memory is full. - allkeys-lru: Valkey evicts the least recently used keys. - allkeys-lfu: Valkey evicts the least frequently used keys. - allkeys-random: Valkey evicts random keys. - volatile-lru: Valkey evicts the least recently used keys that have an expiry. - volatile-lfu: Valkey evicts the least frequently used keys that have an expiry. - volatile-random: Valkey evicts random keys that have an expiry. - volatile-ttl: Valkey evicts the keys with an expiry that expire soonest.

firewallIds string[]

The IDs of the firewalls attached to the instance. An instance can have one firewall.

latestSnapshotAt string | null

When the newest available snapshot was created.

maxConnections number

The most client connections the plan accepts.

members ValkeyMembersItem[]

The instance's primary and replicas, with their addresses in your private networks.

metadata ValkeyMetadataMap

Your own tags as string pairs, at most 10. An update replaces all tags. Set it to an empty object to remove every tag.

name string

The instance's name, up to 255 characters. Must be unique among the organization's live Valkey instances.

networkIds string[]

The IDs of the private networks attached to the instance.

persistence "none" | "rdb"

Whether Valkey keeps the data across restarts. Snapshots work either way. - rdb: Valkey keeps the data across restarts. - none: Valkey keeps the data in memory only, as a pure cache.

preUpgradeSnapshotId string

The ID of the snapshot we created before the upgrade. Later responses don't include it.

publicAccess boolean

Whether the primary accepts connections with TLS on a public IP, on port 6380. The port opens shortly after the change.

replicaCount number

How many replicas the instance has besides the primary, from 0 to 2. We add or remove replicas shortly after the change.

status string

The instance's state. A new instance is ready once it's running. A running instance can still be adding a replica or opening its public TLS endpoint. - provisioning: We're creating the instance. - running: The instance is ready. - degraded: A member doesn't respond. status_message says which. - rescaling: We're changing the plan. - upgrading: We're upgrading the Valkey version. - restoring: We're restoring a snapshot onto the instance. - failed: The instance couldn't be created and stays in this state. - destroyed: The instance is deleted.

statusMessage string | null

What needs attention now, such as a member that doesn't respond or a rescale or upgrade that didn't complete. Is null when all is well.

teamId string

The ID of the team that owns the instance. Can't be changed after the instance is created.

term "monthly" | "annual"

The billing term. Defaults to monthly. A change applies at once, from monthly to annual or back. Billing ends the current term and starts the new one. - monthly: The instance is billed every month. - annual: The instance is paid for a year.

type string

The plan, such as VK2.

updatedAt string

When the instance was last changed.

usableMemoryGb number

Memory for your data on each member, in GiB.

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

availabilityZone string

Zone it lives in, such as us-west-2a. Defaults to the credentials' zone.