Architecture — Layered Environments on One Account
By Engineering & Security Architecture Team•October 25, 2026•4 min read
The account is set up in four layers. The two account-level layers each live in their own repository; the two site layers live in the site’s repository. Decisions: ADR-INFRA-010 and ADR-INFRA-011. Requirements: SR-INFRA-009, whose IDs are used below unless stated. Repository and resource names are placeholders.
The other architecture pages of this application:
- What Each Layer Applies in Cloudflare: responsibilities per layer, and the order the account is set up in.
- Access Hand-Over: which tokens are made by hand, which come from code, and where each goes.
- State Bucket: where every layer’s state lives and how it is copied.
- Zone Baseline: what every site environment gets in its zone.
1. Layers and zones

| Layer | Root module | Applied by, from where | Creates |
|---|---|---|---|
| L1 bootstrap | <bootstrap-repo>/src |
A person, from the bootstrap dev container | The state bucket, the retention lock on its history/ prefix, account alerts (SR-F-02) |
| L2 project setup, non-production | <setup-repo>/src/nonprod |
A person, from the setup dev container | Each site’s non-production zone and its mail records, the non-production pipeline tokens and the non-production personal tokens (SR-F-03) |
| L2 project setup, production | <setup-repo>/src/prod |
The setup-prod workflow, dispatched by hand from main |
Each site’s production zone and its mail records; no token (SR-F-03, SR-F-13) |
| L3 site, non-production | <site-repo>/deploy/infra/nonprod |
The site’s infra.yml workflow, promoted by a person on main; the first setup from the site’s non-production dev container |
Pages project, media bucket, DNS, firewall and TLS in <test-domain> (SR-F-04) |
| L4 site, production | <site-repo>/deploy/infra/prod |
The site’s infra.yml workflow, promoted by a person on main after non-production |
The same resources in <domain> (SR-F-04) |
- One account, one zone per site and environment (SR-F-05). The non-production zone
<test-domain>and the production zone<domain>never share a resource, so a change proven in one can never touch the other. - Same code in both environments. The two L2 roots call one shared module, and so do L3 and L4. Each pair differs only in its inputs (SR-F-06).
- Own state per root. Each root has its own state key under
workloads/and its own passphrase (SR-NF-02). - No production container. Production roots run only in GitHub Actions. The dev container’s guard refuses any production folder or production environment value (SR-F-09).
- Nameservers by hand. The registrar is outside the account, so after L2 creates a zone a person sets its nameservers there (SR-F-10). The zone’s mail records are created in the same L2 run, so the domain’s mail works from the moment of the switch (SR-F-13, ADR-INFRA-012).
2. Why separate repositories and dev containers
| Decision | Reason |
|---|---|
| L1 is its own repository | It is applied rarely, with a hand-made token, so its history, reviewers and access list are kept apart from anything that changes weekly. |
| L2 is its own repository | It holds the only code that creates tokens, and it is shared by every site on the account. Adding a website is one entry in each environment’s domains value and no change in L1 or in another site’s repository. |
| The site repository holds only L3 and L4 | A site’s own buckets, DNS and Pages project change without write access to the code that creates tokens. Its pipeline reaches only its own root module. |
| One dev container per repository and role | A container clones only the repository it needs, so a session never has another layer’s or another site’s code on disk. Containers share no volume. |
3. Data flow of one apply
- A non-production or account-level layer is applied by a person from that layer’s dev container. On the host,
op runreleases the layer’s values after Touch ID into one engine run, which starts in the container as a separate user behind a code guard. Details: Non-Production Apply. - The engine reads the layer’s encrypted state from the state bucket, plans, and the person reads the plan before applying.
- A production layer is applied only by its workflow on
main, and only when a person starts it by hand; a push or merge only plans (SR-NF-04). Details: Production Release. - After an L2 apply, the personal values are piped to the site’s non-production vault, and each new pipeline token is rolled by a person into the site’s vault for that environment, see Access Hand-Over.
4. Free-tier budget (SR-NF-01)
| Resource | Free limit | Use here |
|---|---|---|
| R2 storage | 10 GB, 1 million Class A operations a month | One state bucket and one media bucket per site and environment; state files are small, and test media expires |
| Pages | Unlimited bandwidth | One project per site and environment, published by direct upload from the pipeline, so no Cloudflare build is used |
| Firewall | One rate-limit rule and five custom rules per zone, free managed ruleset | One rate-limit rule and two custom rules per zone; the managed ruleset is on by default (SR-F-11) |
| Certificates | Apex plus one wildcard level | Each zone has its own certificate; the host, www and assets are all one level |
No Worker is used: the media bucket is served through its own custom domain on the zone.