Pulumi Infrastructure
Settled — do not re-propose
- Credentials. Every secret, ESC key and Cloudflare token follows
.agents/skills/security/references/credentials.md, including the rule that no secret sits in a stack file. - One shared token for every consumer. A token every consumer holds widens all of them when one needs a permission, so each consumer gets its own token (
openspec/specs/infra/cloudflare-tokens/design.md). - Rotation or expiry machinery. No scheduler re-rolls a token and no job checks expiry; a token's value changes only when its resource is replaced, as a runbook step.
- A wrapper over
cloudflare.AccountToken. Each token is a plain resource. The one helper allowed is the permission-group lookup two or more tokens share. - An edit to a token's permissions in the Cloudflare dashboard. A permission lives in code, where the preview shows it; a dashboard edit is invisible to review and the next apply reverts it.
- A script that copies stack outputs into ESC.
pulumi env setwrites each output with one command. - Widening
.github/workflows/Pulumi.yaml'spaths:— a gate job over the workspace graph, a content hash at two refs, apnpm-workspace.yamlentry — so a pull request previews on a workspace-package edit or a@pulumi/*bump. Nothing applies to the estate off a pull request:upis local with a preview in front of it (references/operations.md), and the workflow previews only pushes toai/queue(openspec/specs/architecture/monorepo-tooling/design.md→ "What a CI proposal has to beat"). - Adding an observability resource — a telemetry store, an alert rule — as an unprompted best practice. The estate runs with none by a cost decision: paid ingestion recurs with no consumer, so the suggestion is closed, not applied. What a condition worth noticing does instead (
console.error, the dead-letter queue) and what would reopen the decision:openspec/specs/infra/observability/design.md.
Package Shape
The package's shape is references/package-shape.md. The stack holds only what the program declares, so an apply is untargeted once its preview reads clean; --target narrows one only when a preview shows a change the apply must not make yet (references/operations.md).
Cloudflare Rules
- Provider. Every Cloudflare resource is declared with
@pulumi/cloudflare, imported as a namespace (Provider Imports below). - Names. An environment's resource is
<env>-<assetType>-esposter-<purpose>and an account's is<assetType>-esposter-<purpose>.getCloudflareResourceNameandgetCloudflareAccountResourceNameinpackages/db-schema/src/services/cloudflare/build both, for Pulumi and for the Workers, andapps/infra/docs/cloudflare/naming-conventions.mdlists the asset types. A Pulumi logical name is that name. - Secrets. The ESC environment holds them, never Pulumi config, and a change that adds a Worker secret sets its ESC keys itself, unasked. The rule and its lifecycle are
.agents/skills/security/references/credentials.md, and the deploy gate's check isopenspec/specs/architecture/environment/design.md, "Secrets and vars". - Worker code. Pulumi declares what the Workers bind to — queues, queue consumers, buckets, D1 databases, custom domains — and never ships their code. The Deploy workflow (
.github/workflows/Deploy.yaml) runswrangler deployfor the three Workers (realtime,jobs,web, in that order), onmainfor production andai/queuefor development, once CI's run on that commit succeeds.
Resource Files
- One resource declaration per tracked source file; export exactly one resource constant per file, named as the file minus
.ts. Cloudflare resources live undersrc/cloudflare/resources/<resourceType>/, the folder named for the provider type (r2Buckets,queueConsumers, …), and each file is the camelCase of its Cloudflare name (prod-r2-esposter-message-assetsisprodR2EsposterMessageAssets.ts). - A child resource takes its parent's name with its own resource type as a suffix (
prodQEsposterProcessWebhookConsumer,prodR2EsposterMessageAssetsLifecycle). - Every resource carries
protect: trueunless the user explicitly asks for a lifecycle change. An R2 bucket is built bycreateR2Bucket(src/cloudflare/services/createR2Bucket.ts), and a queue consumer bycreateQueueConsumer, orcreateDeadLetterQueueConsumerfor a dead-letter queue, in the same folder; each sets it, andscripts/src/workspace/ci/resourceProtection.test.tsfails on a constructor its file leaves unprotected. - Never add
aliasesto any resource (no-restricted-syntax), and the reason, with the closed review suggestion, isreferences/migrations.md's. - A deployed resource is renamed like any other identifier — rename, preview, read the plan (
references/migrations.md).
Pointing at Another Resource
- A resource with a containing resource sets
parentto it — a queue consumer to its queue, an R2 bucket's lifecycle and event notification to the bucket, a zone's DNS records, ruleset and Workers custom domains to the zone. A queue, dead-letter queue, D1 database, R2 bucket or zone is account-scoped and takes no parent (references/resource-references.md). - Prefer a resource output over a repeated identifier literal; a named constant is earned at two resource files, as the queue consumer retry delay is (
apps/infra/src/cloudflare/constants/QueueConsumerRetryDelay.ts). resource.nameandresource.idareOutput<string>— a plain backtick interpolation and a computed object key both produce"[object Object]"silently, so a template literal takespulumi.interpolateand a key takes a plain-string source of truth.
Provider Imports (namespace, not named)
Provider packages are imported as a namespace (import * as cloudflare from "@pulumi/cloudflare"), and a named import off @pulumi/* is a no-restricted-syntax error (scripts/src/services/oxlint/selectorBan/syntaxes/restrictedImportSyntaxes.ts).
The one exception to named imports from libraries, and a review suggestion to switch is closed: why is references/provider-quirks.md.
Docs
- Durable infrastructure docs live in
apps/infra/docs/, one directory per provider that has any, with the cross-cutting pages at its root. The convention is the layout, not a list:ls apps/infra/docsnames the current set, and each page's title says what it holds. - Open infra work is each its own
infra-change underopenspec/changes/; the area index + shipped log isopenspec/specs/infra/README.md; phase-2 cost/security findings are inopenspec/specs/infra/cost-and-security-posture/design.md. - Move completed one-off migration notes out of the package once their durable content is represented in
docs/.
Deep Dives
references/operations.md— when runninginfra:preview/infra:up, after a catalog bump to a@pulumi/*provider package, or when something reads as deployed but does not work.references/migrations.md— when renaming, re-parenting, or replacing an already-deployed resource, when a review suggests adding analias, or when importing an existing resource withpulumi import --generate-code.references/resource-references.md— when setting a resource'sparent, reading another resource's.name/.id, or choosing between an output and a named constant.references/provider-quirks.md— when touching the GitHubRepositoryresource and its branch protection, a setting the GitHub provider has no field for, or a review that asks for named imports from a provider package.references/package-shape.md— when adding a provider folder or a non-resource stack output, or touching the barrel or the entrypoint.references/queues-and-notifications.md— when a job's messages reach its dead-letter queue, a consumer or an R2 notification names a Worker or queue that is being renamed, or a consumer's Worker is deployed but its jobs do nothing.