Pulumi for the platform only
Many teams split the work: a platform team keeps the account in Pulumi (zones, DNS, Access, shared buckets and databases), and app teams ship their apps. In this setup there’s no App resource in Pulumi at all. Pulumi makes the platform and exports names. The app never writes those names down; it names a key, and the name arrives when it ships.
Names provided at deploy
Section titled “Names provided at deploy”Declare the resource the platform makes with .provided(key):
import { App, R2, Worker } from '@forge-effect/infra';
export class Files extends R2.Bucket<Files>()('files') {}
export const web = Worker.make('web', { fetch }).bind(Files.provided('filesBucket'));
export default App.make('shop', { workers: [web] });The key defaults to the resource’s own name (Files.provided() is
files). R2 buckets, KV namespaces, D1 databases, queues and Flagship
apps can all be provided. The app binds them and checks they exist, but
never makes or deletes them.
Give the names when you plan, ship or promote: one at a time with
--provide, or a whole JSON object of keys and names with --provided.
pulumi stack output --json writes exactly that, and keys the app
doesn’t use are ignored:
pulumi stack output --json -s staging > staging.jsonpnpm infra ship app.ts --env staging --provided staging.jsonpnpm infra ship app.ts --env staging --provided pulumi:acme/platform/staging # or straight from the stackpnpm infra ship app.ts --env staging --provide filesBucket=shop-files-staging # or by handpulumi:<org>/<project>/<stack> runs pulumi stack output for you, so
it needs Pulumi’s CLI and its login where it runs. A secret output is
refused rather than decrypted: a name worth providing isn’t secret.
Forget one, and the plan says what’s missing before anything ships:
! the Worker web binds the R2 bucket files, provided at deploy as filesBucket, and nothing provided it: external-missing; provide its name: --provide filesBucket=<name>, or --provided <file.json> with filesBucket in it (pulumi stack output --json)On the Pulumi side, the program only exports the name:
resources: files: type: cloudflare:R2Bucket properties: accountId: ${accountId} name: shop-files-${pulumi.stack}outputs: filesBucket: ${files.name}A pipeline that builds once
Section titled “A pipeline that builds once”Because the names aren’t in the app, they aren’t in a build either. One build, made before anyone knows what the platform called things, ships to every environment:
# CI, once per commit: the code, and its container images pushed by digestpnpm infra build app.ts --env staging --env production --out build/
# staging, with staging's namespulumi stack output --json -s staging > staging.jsonpnpm infra ship --build build/ --env staging --provided staging.json
# after staging looks right: what ran there, with production's namespulumi stack output --json -s production > production.jsonpnpm infra promote --build build/ --from staging --to production --provided production.jsonpromote ships production’s release of the build only if staging is
running that same build, so production gets exactly what staging ran.
The build directory can be a CI artifact; the machine that ships needs
no source.
Checked live: Pulumi made a bucket and exported its name. A build made
without the name planned with the missing name reported, then shipped
with --provided from the stack’s outputs. Its Worker read the bucket,
and a second plan showed nothing to change.
Who owns what
Section titled “Who owns what”In this setup ecloud (or a deployer) is the
environment’s recorded owner, not a Pulumi stack, so a Pulumi App for the
same environment would be refused. Pulumi still sees the app through
getApp, for anything it needs to
point at it.
With the App resource too
Section titled “With the App resource too”The App resource takes provided names through its externals input,
keyed by binding or by key, so the same app.ts works both ways:
new App('app', { build: config.require('shopBuild'), externals: { filesBucket: files.name } });Not done yet
Section titled “Not done yet”- Through a deployer, the release it’s sent carries the names. That’s built but not tried live.