Architecture — Infrastructure Layers
The infrastructure is split by privilege. Each layer is its own root module with its own state, its own values and its own place to run from, so a credential for one layer can never change another (SR-INFRA-001 SR-F-05). The diagram shows the Cloudflare implementation. Repository names are placeholders.

1. Layers
| Layer | Root module | Environment | Runs from | Creates |
|---|---|---|---|---|
| L1 | <bootstrap-repo>/src |
shared |
L1 bootstrap dev container | State bucket, its history lock, account alerts |
| L2 non-production | <setup-repo>/src/nonprod |
nonprod |
L2 project setup dev container | Non-production zones, personal and pipeline credentials |
| L2 production | <setup-repo>/src/prod |
prod |
setup-prod.yml on GitHub Actions |
Production zones and pipeline credentials |
| L3 | <site-repo>/deploy/infra/nonprod |
nonprod |
infra.yml on GitHub Actions; the first setup and major changes from the site’s non-production dev container |
The site’s non-production resources |
| L4 | <site-repo>/deploy/infra/prod |
prod |
infra.yml on GitHub Actions |
The site’s production resources |
The folder name decides the environment. tofu-guard reads it (prod, nonprod, anything else is shared) and refuses the run when the released INFRA_ENVIRONMENT does not match, and always when it is prod (SR-INFRA-010 SR-F-11). So the two production roots can run only from their workflows.
2. Shared modules
Both roots of a layer call the same module, so non-production and production are built from identical code and differ only in their inputs. A change is applied to non-production first and reaches production through a reviewed merge.
| Module | Used by | Holds |
|---|---|---|
modules/project-setup |
L2 non-production and production | Zones, permission lookups by name, the per-environment personal credentials (non-production only) and the pipeline credentials |
deploy/modules/site |
L3 and L4 | Media bucket, Pages project, DNS records, firewall and rate-limit rules, TLS settings |
3. What each layer creates
What each layer creates in Cloudflare, who applies it and with which credential is described once, in the Cloudflare infrastructure documents: What Each Layer Applies, Zone Baseline, State Bucket and Access Hand-Over.
4. Dependencies between layers
The layers depend on each other in one direction only; the order in which they are applied is in What Each Layer Applies. No layer reads another layer’s state: the guard refuses terraform_remote_state (SR-INFRA-010 SR-F-07). Values a later layer needs, such as a zone identifier, are passed to it as inputs.
Related Documents
- Architecture — Secure Infrastructure Workspace
- Non-Production Apply
- Production Release
- SR-INFRA-001 — Declarative Engine and State Encryption
- SR-INFRA-005 — Bootstrap Workflow and Revocation
- SR-INFRA-006 — Declarative Role Specifications
- ADR-INFRA-001 — Selection of the Declarative Infrastructure Engine
- ADR-INFRA-006 — Management Model for Cloud Roles and Permissions