Use this model when the platform team, not each repository, decides
where state goes. The IaC sidecar passes a backend configuration file to
every init as -backend-config=<file>, and its values override the
repository’s backend block key by key.
Prerequisites
-
Kumoss-managed state turned off with
storage.terraform_state_bucket: ""(see Turn managed state off). Combined with managed state, the file merges into the core’s override and produces a backend neither side fully describes (see Which value wins). -
Every repository declares the backend type, even with an empty body, for example
terraform { backend "azurerm" {} }. A file holds values only and cannot introduce a backend where none is declared. -
An identity for the IaC sidecar that can read and write the state store. The file carries no credentials; see the two credential grants.
Steps
-
Write the backend values as a
.hclor.tfbackendpartial configuration:# backend.hcl subscription_id = "_STATE_SUBSCRIPTION_ID_" resource_group_name = "tfstate-rg" storage_account_name = "acmecentraltfstate" container_name = "tfstates" use_azuread_auth = true# backend.hcl bucket = "acme-central-tfstate" region = "eu-west-1" use_lockfile = trueLeave
keyout of a file every repository shares.keyis a single value, so a shared file that sets it makes every project share one state object. Let each repository declare its ownkeyin its backend block; per-project keys are only automatic under Kumoss-managed state. -
Mount the file into the sidecar and point
IAC_BACKEND_CONFIGat it:# docker-compose.override.yml services: iac: volumes: - ./backend.hcl:/etc/kumoss/backend.hcl:ro# services/iac/.env IAC_BACKEND_CONFIG=/etc/kumoss/backend.hclAn absolute path resolves inside the sidecar container. A relative path resolves against the workspace, which is how a file carried by the target repository is reached. The file must be readable by uid
10001(kumoss), the user the image runs as. An empty or whitespace-only value counts as unset. -
Restart the sidecar:
docker compose up -d iacThe sidecar does not check the path at startup: a workspace-relative file exists only after the clone. A wrong path surfaces as an
initfailure on the first job, in that job’s stderr rather than in the container’s startup log.
Verify
To check all three layers in a deployed environment, see Find the active state.
-
Run a session, then confirm that the core wrote no override. This command must print nothing:
docker compose logs core | grep "Terraform state:" -
In the session’s
initoutput, check that the engine bound the backend from the file, for exampleSuccessfully configured the backend "azurerm"!, and that the state object appears under the key the repository declares.
Next steps
-
Environment variables and secrets: the
IAC_BACKEND_CONFIGentry and the other sidecar variables. -
Backend minimums: the credentials the sidecar needs per backend.