drift slice
Create, resize and operate the slice itself: the environment your project lives in. A Driftfile declares a slice and its shape, and drift apply creates it and resizes it to match, so a project with a Driftfile needs no create command, and drift slice resize below is for the moves a file cannot make yet. drift slice also carries everything that operates a slice once it exists.
Which slice a command acts on. A command that does not read a Driftfile itself acts on the slice DRIFT_SLICE names, and without it on the slice the nearest Driftfile declares, found by walking up from the directory you are in. Nothing is remembered between commands, so a project's commands always act on that project's slice. When the Driftfile decided, the command says so once: slice orders, from ./Driftfile. Outside any project, name the slice with DRIFT_SLICE=<name> drift slice info. A Driftfile with environment blocks names its default slice; reach an environment's slice with DRIFT_SLICE, or use drift plan staging and drift apply staging.
| Command | Description |
|---|---|
drift slice list | List your slices (* marks the one this directory's Driftfile or DRIFT_SLICE names) |
drift slice info | What the slice's scheduler is holding and refusing right now |
drift slice resize [name] | Draw the slice's shape opened on what it already is. Defaults to the slice this directory's Driftfile names. |
drift slice restart | Restart your slice. It is unavailable for tens of seconds; see what replaces the instance |
drift slice warmup | Bring a cooled-down slice back before traffic arrives. See A slice that was cooled down |
drift slice auth | Show or remove the HTTP Basic-auth gate in front of the slice's Canvas site. The gate is declared as site_auth in the edge block. |
drift slice link | Show the slices this slice can call. Links are declared as links in the edge block. |
drift slice domain | Verify, list or remove custom hostnames. Hostnames are declared as domain blocks in the edge block. |
drift slice delete <name> [--yes] | Delete a slice and everything in it (irreversible) |
drift slice transfer | Hand a running slice to another Drift account. See Transfers |
What replaces the instance
A slice is one instance, never two, because its data sits behind a single-writer lock. So replacing it is downtime: calls in flight get up to 10 seconds to finish, new calls are answered 503 by the edge with no queue or retry, and the new instance takes tens of seconds to start and to receive its keys. Drift also replaces slices itself when it rolls a platform update, at most three at a time.
| Operation | Replaces the instance? |
|---|---|
drift slice restart | Yes |
| A resize that changes the total memory booked | Yes. drift plan says so on its Restart line. |
| Accepting a slice transfer | Yes, once, to learn the slice's new address. |
| Deploying a Function or a Worker | No. It is registered into the running slice. |
| Changing egress, or a slice link | No. The new limits reach the running slice. |
| Any other resize | No |
A slice that was cooled down
A free slice that no request has reached for 30 days is scaled to zero to free its memory. Nothing about it is lost: its data and its disks stay where they were, and drift slice list marks it cooled down. A slice that declares a Worker or a scheduled job is never cooled, and neither is a slice you pay for.
What brings it back is a request. A visitor to its site sees a short holding page that reloads itself and then the site, about twenty seconds later. An API call gets 503 with Retry-After for that long. Any drift command that needs the slice wakes it and waits, saying so once on stderr, for up to three minutes.
drift slice warmup wakes it on purpose, for the minute before a demonstration, and returns when it is running. On a slice that is already running it does nothing.
A slice that was stored away
A free slice that no request has reached for 180 days, and that has been cooled for the last 30 of them, also gives back its disks. Its data is saved as one sealed archive, read back and checked against what the slice holds, and only then are the disks removed; drift slice list marks the slice stored away. If the archive is short of anything, the slice keeps its disks. A slice with a function deployed, a Worker, a scheduled job or a trigger, one that holds a NoSQL collection or realtime channels, and a slice you pay for are never stored away.
Bringing it back restores the archive, which takes minutes rather than seconds, in proportion to what the slice holds. A visitor to its site sees a page that says it is being restored and reloads itself. An API call gets 503 with Retry-After and the header X-Drift-Restoring: 1. Any drift command that needs the slice restores it and waits, saying so once on stderr, for up to twelve minutes. drift slice warmup does the same on purpose and tells you it will take a few minutes. While the slice is coming back, drift slice list marks it being restored.
The archive stays in the slice's snapshots, named hibernation- and the date, after the restore. It is an ordinary snapshot: drift slice snapshot list shows it and drift slice snapshot delete removes it.
What a slice is doing right now
The runtime admits work against a per-function memory pool, learns each pool's booking from the peak memory of every invocation it reaps, and stops an invocation that overruns rather than letting it take the slice down with it. drift slice info is the read on all of that:
$ drift slice info
my-slice
compute 340MB of 512MB held (66%)
in flight 2 invocation(s)
warm workers 3 parked
pools
post:webhook 12MB of 32MB held (37%)
get:report 190MB of 256MB held (74%)A limit reported as unbounded means no ceiling could be read, not a generous one. Read this when something is slow; drift file benchmark answers the other question, what a function has actually cost and what it should book.
Changing a slice's shape
A Driftfile declares a slice's shape, and drift apply writes it. Each Function's and Worker's memory booking, each database's, collection's and bucket's size, and the slice-wide limits are written in the file, and drift apply creates the slice when it does not exist and resizes it when it does. drift plan shows the price the platform quotes for the shape first, and drift apply asks you to agree to it. See drift plan and drift apply.
drift slice resize changes a slice without a file. A slice begins as a Driftfile (drift file new writes one) and drift apply, which creates it and quotes the price first. Every resource, every limit and the price of the lot are chosen there. A slice that a Driftfile declares takes its shape from the file: a resize made by hand shows up in the next drift plan as a difference, and drift apply resizes the slice back to the file unless the file says the same.
The default path for either is a form that recomputes the total as you type. It is a tree you move around in: arrows move, space folds a section, and typing edits the row you are on directly, a function's row is its route, so you highlight it and start spelling. ^D removes an item, Esc discards a half-typed one. Everything is collapsed to begin with, so the parts you never open stay at the platform's own defaults. The price comes from the server on every edit; the CLI ships no rates of its own, so the figure above Apply is the figure you are charged.
For a resize, that gives one path for a change in any direction, up or down:
drift slice resize # the slice this directory's Driftfile names
drift slice resize my-slice # or a named oneA resize is refused twice on purpose, and each refusal is answered on the form itself rather than by starting again. Booking memory per function for the first time reprices the whole slice, so it is refused until you agree to the new figure: the button changes to say what it now costs, and pressing it again is the agreement. A change that takes something away is refused until you confirm it, after the form has listed what would go.
A priced slice resized to a shape inside the free grant moves to the free tier itself, once you agree to its price of nothing. The move needs a free slot, and everything the slice holds must fit what the free shape grants: NoSQL and blob bytes per item, the SQL database's bytes and count, the queue's depth, the number of secrets. Making the move credits the unused remainder of the paid period to your balance, once, and drops the period; the shape the slice leaves is kept in its history. Refused, it says why before anything is charged: every free slot already held, naming them; an item that holds more than the free shape allows, naming it; or a slice the platform cannot ask what it holds. A resize to a shape inside the free grant that does not agree to a price of nothing stays priced, as it always has.
Resizing without a terminal
The form needs a TTY, so a script, CI job or SDK consumer cannot draw it. --dump and --config answer the platform's same two questions from flags instead of from the form (for a slice with a Driftfile, drift apply is the scripted path, and --approve-price and --approve-remove are its answers):
drift slice resize my-slice --dump > shape.json # what it is now
$EDITOR shape.json # what it should be
drift slice resize my-slice --config shape.json \
--acknowledge-monthly-cents 1200 # yes, at that price--dump writes the slice's current shape as JSON to stdout; edit it and feed it back with --config. A resize that changes what the slice costs is refused until --acknowledge-monthly-cents sends back the new figure in cents; one that takes something away is refused until --confirm <slice-name> names the slice. Each refusal states the figure or lists what would be lost, the same information the form's own row shows, so a second attempt can answer it exactly.
drift apply creates a slice and resizes one.
drift slice resize, which is why that command stays. For a slice without a file, growing and shrinking are the same act, and both happen at the resize form, or through --dump/--config, which is also where a reduction that would strand data is refused, with each offending resource named against its current usage.The interactive form needs a terminal.
resize, --dump/--config is the path that works anywhere.Transfers
Hand a running slice to another Drift account. You offer it to an account by name, and nothing changes until that account accepts. The slice keeps running throughout: its data and its custom domains stay where they are, and its price moves with it. Its address changes to one named after the new account; the old address redirects to the new one for 30 days and then stops answering.
| Command | Description | |
|---|---|---|
drift slice transfer offer <slice> --to <account> | Offer one of your slices to another account. It shows the address the slice has now and the one it has after accept, and you retype the slice's name to confirm. | |
drift slice transfer list | List the offers you made and the ones made to you, with price, status and expiry | |
| `drift slice transfer accept <slice\ | offer-id>` | Accept a slice offered to you, after reading its tier, price, billing, its address and its old address |
| `drift slice transfer decline <slice\ | offer-id>` | Decline an offer made to you; the slice stays with the account that offered it |
| `drift slice transfer cancel <slice\ | offer-id>` | Withdraw an offer you made |
drift slice transfer offer my-shop --to bakkerij # you
drift slice transfer accept my-shop # themOffering and accepting both ask for your password again. Only the account an offer names can accept or decline it, and only the account that made it can cancel it. An offer expires after seven days, and a declined, cancelled or expired offer cannot be accepted later. An offer to a name that is not a Drift account is never accepted; it expires.
Accepting moves the slice, everything in it and its bill to your account, and the slice disappears from the previous owner's drift slice list. Its snapshots go with it. Both accounts' audit trails record the handover, and the slice restarts once, within a few minutes, to learn its new address.
Some things refuse a transfer until you remove them.
links in the Driftfile and run drift apply) or with alerts set cannot be offered or accepted. An account that already holds all three of its free slices cannot accept another free one, and an account cannot accept a slice whose name it already uses: the name would be the address both would have had.The address changes to the new owner's name. The old one redirects for 30 days, then stops answering.
Linking
Let a slice call another slice you own and that sits in the same name space, without the call leaving Drift (e.g. an app calling your own observability slice). A slice you received from another account cannot link to the slices you created. From code, reach the linked slice with drift.Edge.Slice("<name>"); drift.Slice("<name>") is the deprecated spelling of the same call.
Links are declared in the Driftfile, with links in the edge block, and there is no command that adds or removes one. When it is written it is the whole list: drift apply adds the links it names and removes the ones it does not, and drift plan shows both (each removal is asked about). Leave it out and the links are left as they are.
slice "demo" {}
edge {
links = ["billing", "observability"]
}| Command | Description |
|---|---|
drift slice link list | List the slices the active slice is linked to |
Links covers how a linked call travels and what it can meet on the way.
Site gate
Guard the slice's Canvas site with HTTP Basic auth: anyone without the credential gets a 401 and never reaches the site. This gates the site itself, not the API; drift atomic auth guards a function separately.
The gate is declared in the Driftfile, with site_auth in the edge block, and there is no command that sets credentials. Each password is written env("NAME"), the name of an environment variable read when drift apply runs, so no password is ever written in the file (a literal is refused); an unset variable refuses the apply before anything deploys. When the block is written the users it names are exactly who can sign in. Leave it out and the gate stays as it is, on or off.
slice "demo" {}
edge {
site_auth {
realm = "Staging"
paths = ["*"]
user "alice" {
password = env("ALICE_PASS")
}
}
}disable is the only way to switch the gate off: no declaration does that.
| Command | Description |
|---|---|
drift slice auth list | Show whether the gate is on, and who can sign in |
drift slice auth disable | Remove the gate; the site becomes publicly reachable again |
disable asks for confirmation, being the one direction that exposes something. The site gate shows each command's output and what a visitor sees.
Snapshots
Portable backups of a whole slice: source code, data, secrets, and sites. Your source comes back as you wrote it, with every Drift-generated wrapper stripped out; the only Drift files in the archive are two manifests that sit beside the tree rather than inside it.
| Command | Description |
|---|---|
drift slice snapshot create [--name label] [--passphrase] | Snapshot the active slice (polls until ready) |
drift slice snapshot list | List snapshots with id, name, size, and status |
drift slice snapshot download <id> [-o path] | Download a snapshot archive |
drift slice snapshot restore <id> | Restore a snapshot into the active slice |
drift slice snapshot delete <id> [--yes] | Delete a snapshot |
Cache and locks are not in the archive.
Encryption, and your own passphrase
Snapshots are stored encrypted. Each archive gets a key of its own, and that key is held wrapped by the platform, so the object store holds ciphertext and a restore can run without you present. The file you download is a plain .tar.gz, and it holds this slice's secrets in cleartext. The CLI writes it 0600 and says so every time.
--passphrase changes who can open the archive. Drift prompts for one, derives the archive's key from it, and uses that instead of the platform's key. Downloading or restoring that snapshot asks for the same passphrase.
A passphrase you forget cannot be recovered, by you or by us.
drift slice snapshot list marks the protected ones, so you can see which those are before you need them.--passphrase-stdin reads the passphrase from stdin instead of prompting, on create, download and restore, for scripts. There is deliberately no flag that takes the passphrase as a value: it would land in ps and in your shell history, and unlike a password this one can never be reset.
What the passphrase protects is the archive at rest, in the object store and on whatever holds a copy of it. Drift builds the archive from your slice, so the contents pass through the platform when you create one and again when you open one. Encrypting in the CLI instead would change that, at the cost of an archive an older CLI could not read.
Custom domains
Point your own hostname at a slice; Drift verifies ownership and issues the TLS certificate. See Getting started for a walk-through and Hostnames and domains for the full flow.
Hostnames are declared in the Driftfile, with domain blocks in the edge block, and there is no command that adds one. drift apply attaches every one the slice does not have yet, prints the DNS records to create, and never removes one; verifying stays a command, because it needs your DNS to be live first.
slice "demo" {}
edge {
domain "forms.example.org" {}
}| Command | Description |
|---|---|
drift slice domain verify <host> | Re-check the TXT record and, on success, issue the certificate |
drift slice domain list | List custom hostnames for the active slice |
drift slice domain remove <host> | Remove a hostname, its certificate, and its routing |
wildcard = true inside the domain block routes every subdomain of the host to this slice as well. It is routing only. Every subdomain reaches the slice, and each one gets its own certificate issued on demand, and there is no wildcard certificate. Telling alice.example.com from bob.example.com is your app's job; the platform hands both to the same slice.
A verified hostname can also be served by another slice of yours, declared as hosts = { "app.example.com" = "frontend" } in the edge block: the request is answered by the linked slice, with that slice's rate limit, gate and allowlist.