Architecture — Non-Production Apply

By Engineering Team•November 29, 2026•6 min read

This is how a person applies a non-production or account-level layer (L1, L2 non-production or L3, see Infrastructure Layers) from its dev container. It implements SR-INFRA-010, whose IDs are used below, and SR-INFRA-002 for the release of values.

Every check sits before the engine starts, and the first one sits before any value is released.

Non-production apply: the person runs the host script; a production folder or an unflagged apply is refused before any value is released; 1Password releases the values; the engine starts as deployer through tofu-guard; the guard refuses a mismatched environment, copies the project and refuses code, lock file or environment that fails its checks; the engine runs, writes encrypted state, and the host copies it to history


1. Steps

Step Where What happens
1. Start Host The person runs tofu-in-container.sh with the container, the module folder, a file of variable names, and the engine command.
Check Host Refused when the module folder is a prod folder, when the command is anything other than init, plan, validate, import or apply, or when it is apply without --allow-local-apply. Nothing has been released yet. (SR-F-04, SR-F-11)
2. Release Host op run asks for Touch ID and resolves the layer’s 1Password Environment, or the references in the file, into the environment of the one command it starts. (SR-F-03)
3. Hand over Host → container docker exec -u deployer starts tofu-guard in the container’s module folder. Each variable is passed by name only, so its value is on no command line and not in the container definition. INFRA_ENVIRONMENT is always passed. (SR-NF-01)
Check Guard Refused when INFRA_ENVIRONMENT is prod or does not match the folder, when the engine’s data folder is outside deployer’s home, or when an environment variable is set that could redirect logs, configuration, encryption or the provider address (TF_LOG*, TF_CLI_ARGS*, TF_CLI_CONFIG_FILE, TF_ENCRYPTION, the provider’s base URL). (SR-F-08, SR-F-11)
4. Copy Guard The project is copied, without .git, build output or engine caches, into a folder only deployer can write. Saved plans and local state are kept between runs, everything else is replaced. (SR-F-06)
Check Guard The copy is checked. Details are in the next section. A refusal prints the reason and the file and line. (SR-F-07, SR-F-09)
5. Run deployer The engine runs from the copy, with the root-owned configuration that downloads only allowlisted providers. init always gets a read-only lock file.
6. State Provider The engine writes state encrypted on the client to workloads/<module>.tfstate in the state bucket. Plans are saved in deployer’s folder, unreadable by vscode.
7. History Host After an apply, the person runs state-history-copy.sh through op run. It makes a server-side copy of the encrypted state to history/<module>/<time>-<digest>.tfstate.encrypted, and skips it when a copy with the same digest exists. (SR-F-13)

The person reads the plan before every apply. The guard checks the code, not what the provider will do with it. (SR-NF-04)


2. What the guard checks in the copy

Check Refused when Why
Symbolic links Any link in the copy A link could point the run back into the editable workspace
Configuration format Any *.tf.json or *.tofu.json file JSON configuration is not checked, so it is not allowed
Variable files A .tfvars file in the module It would override the values the host passed
Provisioners Any provisioner It runs a program with the released values in its environment
Remote state Any terraform_remote_state It configures a backend from code and can send values to it
Provider address Any base_url It sends the credential to a host the code chooses
Cloud block Any cloud { } It sends state and values to another host
State encryption A key provider other than pbkdf2, or a method other than aes_gcm The others run a program or call a remote key service
Backend A backend other than s3 or local, or a backend setting that is not a plain literal No value may reach the backend address
Module source A source that is not a plain literal No value may reach a download address
Lock file No .terraform.lock.hcl, or a provider in it that is not in the allowlist Only reviewed providers run. Never external, local, http or null, which can run a program, write a file or send a value anywhere (SR-F-09)
Plugin folder -plugin-dir on the command line It loads providers from a folder the policy does not control

The modules the engine downloaded into its data folder are checked the same way. Any check that cannot be made refuses the run. (SR-NF-02)


3. What each user can see

vscode (editor, assistant) deployer (engine)
Released values Never In its process environment only
Workspace code Reads and writes Reads, through the group
Private copy, plans, plugins No access Owns them
Guard, allowlist, policy Reads Reads