Concrete project, instance, and bucket IDs are located exclusively in the ignored file .local/deployment.json. In the repository, only infra/foundation/deployment.example.json is present. Region: eu01.
| Resource | Value |
|---|---|
| Secrets Manager | kolibri-stackit-agent |
| Instance ID | <SECRETS_MANAGER_ID> |
| Vault-compatible API | https://prod.sm.eu01.stackit.cloud |
| S3-Bucket | <PRIVATE_STATE_BUCKET> |
| S3-Endpoint | https://object.storage.eu01.onstackit.cloud |
| VM-State object | kolibri/terraform.tfstate |
| Foundation-State object | foundation/terraform.tfstate |
infra/foundation/main.tf manages Secret Manager instance, bucket, and credential group. prevent_destroy protects these three resources from accidental deletion by OpenTofu. Object Storage must be activated in the project. Versioning and AES256 default encryption are additionally set with project-secrets.py configure-bucket. The bucket has no public ACL. The S3 credentials and the Secrets Manager user are created outside of Terraform; thus their passwords are not in the State.
Both IaC components use the versioned S3 bucket directly as the active backend. infra/compute/backend.tf and infra/foundation/backend.tf contain no bucket or project ID. The tofu shell function from scripts/env.sh loads the S3 credentials from the Secret Manager into the process environment and, at init, appends the bucket from .local/deployment.json. The project parameter is also taken from this local configuration.
use_lockfile = false is explicitly configured: the project operator uses the project alone and requested this operation without a distributed state lock. The shell function continues to serialize calls within the same working copy. Calls on multiple machines must not write simultaneously.
OpenTofu reads and writes the relevant States directly under the two S3 keys mentioned above. Bucket versioning retains previous versions; AES256 encryption and private access rights remain active. Local recovery files are not an active state.
backup-state reads the current S3 states and creates additional verified copies under snapshots/<ID>/.... It never overwrites the active S3 state with an old local state. Direct .tools/tofu calls require manually set S3 credentials; therefore, in normal operation, always run source scripts/env.sh first.
All following paths are located in the KV-v2-Mount of the above-mentioned instance under kolibri/:
| Prefix | Content |
|---|---|
operator/ |
Project service account, SSH key, known SSH hosts, WebUI bootstrap access, previous Basic Auth credentials and private deployment variables |
runtime/ |
knowledge.env, webui.env, media.env, admin.json, previous Caddy credentials, .env, SearXNG configuration including search service key |
caddy/ |
Snapshot of ACME accounts, TLS keys and certificate files |
infrastructure/s3 |
Access Key and Secret Access Key for the state bucket |
infrastructure/secrets-manager-user |
Backup of the technical secret manager access |
The optional download-only Hugging Face read token is kept in .local/huggingface.token (0600) and backed up as operator/huggingface.token. It is not injected into serving containers. Older backups without this optional credential remain restorable.
Files are stored losslessly as content_b64; Base64 is only an encoding. Secret Manager handles encryption and access control. Every write operation is immediately verified by reading and comparing contents. No secret values are output.
The services continue to use their existing root-protected files under /opt/kolibri/.secrets. Secret Manager is their central backup and restore repository; changes there are not automatically distributed to running containers. After a rotation or deployment configuration change, run backup. New secret files must be added to LOCAL_FILES, OPTIONAL_LOCAL_FILES or REMOTE_FILES of the script. The TLS backup is a snapshot and is only updated upon a new backup.
User data, password hashes and sessions in the WebUI database as well as old deployment archives are not a central credential configuration and were not copied into the Secret Manager as a database export. A complete backup of chat/application data is a separate task.
Prerequisites: STACKIT CLI, OpenTofu 1.11+, Python 3 with requests and boto3, SSH. Install Python packages in a virtual environment if needed:
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -r scripts/operations-requirements.txt
source scripts/env.sh
# Back up deployment secrets, including the TLS snapshot:
python3 scripts/project-secrets.py backup
# Create and verify additional snapshots of the active S3 states:
python3 scripts/project-secrets.py backup-state
# Check versioning, private ACLs and both state objects:
python3 scripts/project-secrets.py verify
# Regular IaC operations using the active S3 backend:
tofu plan -var=availability_zone=eu01-3Secret-Manager bootstrap is located locally at .local/secrets-manager-user.json (0600); this single access is required to read further credentials. It must never go into the repository. Additionally store the project service account securely outside this system: a key stored alone in the same Secret Manager would not be an independent recovery path.
-
Clone the repository, install dependencies and run
scripts/install-tofu.sh. -
Securely provide the private deployment configuration as
.local/deployment.jsonand the Secret-Manager access as.local/secrets-manager-user.json(directory 0700, files 0600). The public example shows only the required field names. The actual values are passed outside of Git. The private deployment configuration is additionally secured askolibri/operator/deployment.jsonin the Secret Manager. -
If the technical Secret-Manager access is missing, create a new access using the independently stored project service account file:
source scripts/env.sh kolibri_auth python3 scripts/project-secrets.py bootstrapExisting S3 accesses are reused. New Secret-Manager users do not automatically revoke old users.
-
Restore operator files and directly initialize the existing S3 backend:
python3 scripts/project-secrets.py restore-operator source scripts/env.sh tofu init tofu -chdir=infra/foundation init tofu plan -var=availability_zone=eu01-3 tofu -chdir=infra/foundation planDo not copy local state and do not start a state migration on a new checkout.
initreads the existing state from S3. Existing local operator files are not overwritten byrestore-operator.
restore-state loads current or historical S3 state versions into .local/state-restore/ for review only. It does not change the active state and does not overwrite existing check files:
python3 scripts/project-secrets.py restore-state
# Or select a specific historical version:
python3 scripts/project-secrets.py restore-state kolibri/terraform.tfstate VERSION_IDAn older state is not an infrastructure rollback. It must be reconciled with the actual resources before a targeted recovery. Normal updates use the S3 backend directly; additional local backup files are not required for this.
restore-runtime stores the secured application files locally under .local/runtime-restore. The command overwrites neither running services nor existing recovery files. Before manual transfer to a replacement server, check content, file permissions, and required container restarts.
Compute variables live in infra/compute/environment.auto.tfvars.json; the generated search configuration lives at .secrets/search-settings.yml on the VM. The backup tool preserves their existing Vault keys (operator/environment.auto.tfvars.json and runtime/searxng-settings.yml) so a restored checkout uses the current layout without duplicating secrets.
The optional media VM has no public IP. Its SSH and job API ingress are restricted to the application NIC. scripts/project-secrets.py backup stores its private .env and .secrets/media.env under media-runtime/ and its operator metadata under operator/media-deployment.json. restore-media-runtime restores these files locally for review. The signing key is shared with the previous media deployment only to preserve existing artifact links; never rotate it implicitly during migration. The existing compute state in S3 includes the media resources and storage-performance tracking.