The App resource
effectivecloud:index:App is one environment of one app. Pulumi keeps
its inputs and outputs; Effective Cloud’s own library, running inside the
provider, plans it in a preview and ships it in an update. It’s modelled
on Helm’s Release: Pulumi drives, and the tool it drives keeps the truth
(here, in Effective Cloud’s state in D1).
From its module
Section titled “From its module”The simplest form names the app’s module, and the provider builds it as it ships:
resources: files: type: cloudflare:R2Bucket properties: accountId: ${accountId} name: shop-files-${pulumi.stack} app: type: effectivecloud:App properties: module: ./app.ts # its App.make(...), from the program's directory externals: files: ${files.name} # the bucket app.ts binds with Files.external(...) or Files.provided()The same in TypeScript:
import { App } from '@effectivecloud/pulumi';import * as cloudflare from '@pulumi/cloudflare';import * as pulumi from '@pulumi/pulumi';
const accountId = new pulumi.Config().require('accountId');const files = new cloudflare.R2Bucket('files', { accountId, name: `shop-files-${pulumi.getStack()}` });const app = new App('app', { module: './app.ts', externals: { files: files.name } });
export const plan = app.plan;The TypeScript SDK is @effectivecloud/pulumi. It isn’t published yet;
it installs from a local tarball into any Pulumi TypeScript project,
CommonJS (as pulumi new typescript makes one) or ES modules, with
@pulumi/pulumi as a peer. YAML programs need no SDK.
The stack’s name is the environment unless env says otherwise, so
pulumi up -s staging ships shop-staging-*, and -s production ships
shop-*.
From a build
Section titled “From a build”For the pattern most teams use in CI (build once, then deploy what was built, by reference), pass a build instead of the module:
# in CI, once per commit: into a bucket, or a directory (--out build/)pnpm infra build app.ts --env staging --env production --out r2://shop-buildspulumi config set shopBuild r2://shop-builds/2be70ff3…config: shopBuild: { type: string } # r2://<bucket>/<build id>, or a directoryresources: app: type: effectivecloud:App properties: build: ${shopBuild}The App ships the build’s release for its stack’s environment, with no
source in the program. A build is a directory, or the same in an R2
bucket (r2://<bucket>/<build id>): each environment’s
release (its declarations, and each Worker’s code and files by their
SHA-256), with container images already pushed by digest. Its code is the
same in every environment, so what reaches production is what ran in
staging.
- Switching from module to build changes nothing on Cloudflare. The same code plans the same either way. Pulumi shows it as an update all the same: it uploads nothing, since the versions match, and records which build runs, so the environment can be promoted from straight away. Moving back records that no build runs.
- A preview names the build. The checked inputs carry
buildId, sopulumi preview --diffshows which build is about to ship. - Shipping a build records it, so
infra promote --from staging --to productioncan promote what the stack runs.
Typed by the app (TypeScript)
Section titled “Typed by the app (TypeScript)”Something YAML can’t do: where the program can see the app’s source, as
in a monorepo, give App the app’s type, and the compiler holds its
externals to the keys the app’s names are
provided by. Every key
needs a name, and a key the app doesn’t have is an error:
import type shop from '../shop/app.ts'; // a type only: erased, so a build works too
new App<typeof shop>('shop', { build: config.require('shopBuild'), externals: { filesBucket: files.name } });
new App<typeof shop>('shop', { build, externals: { filesBuckt: files.name } });// ~~~~~~~~~~ not one of the app's keysA .provided() with no key is keyed by its resource’s declared name.
A resource the app binds by its name in the account (.external(name))
may be named in externals too, by its declared name, and is checked the
same way; those are optional.
Through a deployer
Section titled “Through a deployer”Give via a deployer’s URL, and the machine running
Pulumi needs no Cloudflare token: only the deployer’s key
(SHIP_DEPLOY_KEY), or an Access service token it lets in
(CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET).
new App('shop', { build: config.require('shopBuild'), via: 'https://deployer.example.com' });- Check builds the release here (or reads the build’s), sends the
deployer the files it lacks, and has it plan, as the stack. The preview
shows that plan;
fingerprintis its id, the same if made again. - Update has the deployer ship exactly that plan, or nothing if what it read changed since. The secrets it sets go with that request; the deployer sets them and keeps no value. The environment’s owner is the stack, as without a deployer.
- Refresh and delete go through it too: its outputs, and a teardown from the declarations last shipped.
A build in a bucket (r2://…) is read by the deployer itself, so the
program needs neither a token nor the build’s files: build: r2://shop-builds/<id> from config, and via.
Checked live, with a throwaway deployer and a stack run from a shell with
no Cloudflare token: shipped and smoke-tested, the stack recorded as the
owner; previewed again, unchanged; a secret rotated (planned as a new version (secrets set)), shipped, and answered by the Worker; refreshed;
destroyed. The deployer’s bucket and its runs held no secret’s value.
What it takes
Section titled “What it takes”| Input | |
|---|---|
module |
The app’s module, its App.make(...), as a path from the program’s directory. Or build. |
build |
A build, as infra build makes it: its directory, or r2://<bucket>/<build id> in a bucket. Or module. |
env |
The environment. The stack’s name if not given; production keeps plain names. |
via |
A deployer’s URL to ship through, which holds the Cloudflare token. See Through a deployer. |
secrets |
Values for the secrets the app declares, by their names: { 'stripe-key': config.requireSecret('stripeKey') }. Each goes up with the new version of the Workers that bind it, when it’s new or changed. Taken away once the app no longer declares it, it’s deleted from them; while the app still does, that’s refused. Kept encrypted in Pulumi’s state, marked secret or not; never in Effective Cloud’s. |
externals |
Names for what the app binds outside itself, from other resources: by binding, or by the key one is provided by. Pulumi then makes them first and deletes them last, and a preview fails if the app binds a different name. |
steps |
The rollout, in percent: [10, 50, 100]. [100] is all at once. |
smoke |
Whether each step is smoke-tested. Yes by default. |
atomic |
All the app’s Workers move their traffic at once. |
allowBreaking |
Ship a contract change that breaks another app calling this one. |
takeRoutes |
Take a route another Worker serves. |
allowDataLoss |
Deleting this resource may delete its data. Production needs it, set in an update before the delete. |
What it gives
Section titled “What it gives”The App’s outputs are the environment, as getApp and infra outputs
report it: app, env, owner, workers (each with its script, URL,
routes, domains and deployment), resources (each with its name in the
account and its Cloudflare id), and links (what it binds outside
itself, and what binds it). Also plan, the lines its last preview or
update planned, and buildId when it ships from a build.
What each Pulumi step does
Section titled “What each Pulumi step does”| Pulumi | The provider |
|---|---|
| Check (every preview and update) | Loads the app and checks it offline, or reads the build’s release, checked against its hashes. Then plans it against the account. An error stops the preview, with its code. The plan’s lines, and a hash of what it read (fingerprint), become inputs. |
| Diff | A change if the plan changes something. A new environment or app name replaces the App. |
| Create, Update | Ships exactly what Check planned. If anything the plan read changed since, nothing ships (PlanStale). The ship’s log shows under the App as it runs. |
Read (refresh, import) |
The environment’s outputs. An app shipped with infra ship imports by its id, <app>/<env>, without a new version. |
| Delete | A teardown, from the declarations it last shipped, so the module or build may already be gone. |
| Cancel | Interrupts the ship, which undoes what it did. |
What you review is what ships. pulumi preview says the plan under
the App:
Diagnostics: effectivecloud:index:App (app): planned: 3 changes + Worker shop-dev-web: new, live at once ~ workers.dev URL and preview URLs: off → on ~ rollout: 100%and pulumi preview --diff shows the plan input’s change too (Pulumi’s
Node SDK has no detailed diff, so old lines against new):
~ effectivecloud:index:App: (update) ~ fingerprint: "b59058f5…" => "0fd6459a…" ~ plan : [ "~ Worker shop-dev-web: a new version (code); now 100% on b619c7bc", "~ rollout: 100%" ]With Pulumi’s update plans (pulumi preview --save-plan plan.json, then
pulumi up --plan plan.json), an update stops if the code or the account
changed since the review.
Credentials
Section titled “Credentials”The provider reads them from the environment, as infra does:
CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, and
CF_ACCESS_CLIENT_ID with CF_ACCESS_CLIENT_SECRET for smoke tests
behind Access. Pulumi ESC can set them. Through a deployer, only the
deployer’s key or Access service token: the deployer holds the rest.
Not done yet
Section titled “Not done yet”- From a module, a Dockerfile change on its own isn’t seen: its image is built only as it ships. From a build it is, as the build’s images have their digests, which the plan compares with the deployed version’s.
- A Secrets Store secret isn’t an input yet; set it with
infra secret put. (Worker secrets are:secrets.) - Types aren’t checked in a preview (
infra checkdoes that). - A long rollout holds Pulumi’s stack lock for as long as it runs.
- Not published; only a TypeScript SDK so far.