Getting started
Try tegata on your own machine in about ten minutes, without a cloud account: make secrets, fill a template with them, and rotate one. Then move the same setup to Google Cloud Secret Manager.
You need the tegata executable (Install). The example uses only the built-in providers, so tegata init is not needed.
1. The configuration
Section titled “1. The configuration”Copy examples/minimal and work in it:
cp -r examples/minimal /tmp/tegata-try && cd /tmp/tegata-trytegata.yaml declares where secrets live, who reads them, and what to make. Each secret lists its readers; previous is read by the readers of the value it copies:
stores: main: local: dir: ./store # plain-text JSON files: for trying tegata only
identities: app: [serviceAccount:app@example.iam.gserviceaccount.com]
resources: session_key: provider: random # 32 random bytes config: { bytes: 32 } stores: main: - { name: SESSION_KEY, readers: [app] } previous: { name: PREVIOUS_SESSION_KEY } admin_password: provider: manual # you type it stores: main: - { name: ADMIN_PASSWORD, readers: [app] } mail: provider: value # a fixed, non-secret value config: { from: "Example <noreply@example.com>" } stores: main: - { output: from, name: MAIL_FROM, readers: [app] }templates/app/app.env is the file a server running as app fills in. tegata check app templates/app makes sure app can read every name in it:
SESSION_KEY=__SESSION_KEY__PREVIOUS_SESSION_KEY=__PREVIOUS_SESSION_KEY__ADMIN_PASSWORD_SHA256=__ADMIN_PASSWORD|sha256__MAIL_FROM=__MAIL_FROM__2. Check and apply
Section titled “2. Check and apply”$ tegata check app templates/appok$ tegata applycreated secret ADMIN_PASSWORDreaders of ADMIN_PASSWORD: serviceAccount:app@example.iam.gserviceaccount.comadmin_password: no value yet (put it with `tegata set admin_password`)created secret MAIL_FROMreaders of MAIL_FROM: serviceAccount:app@example.iam.gserviceaccount.comMAIL_FROM: version 1 (from mail)created secret SESSION_KEYreaders of SESSION_KEY: serviceAccount:app@example.iam.gserviceaccount.comcreated secret PREVIOUS_SESSION_KEYreaders of PREVIOUS_SESSION_KEY: serviceAccount:app@example.iam.gserviceaccount.comSESSION_KEY: version 1session_key: generation 1PREVIOUS_SESSION_KEY: version 1 (the value of SESSION_KEY)apply made the random key, and gave the members of app read access to the four secrets. The manual password waits for you:
$ echo 'correct horse' | tegata set admin_passwordADMIN_PASSWORD: version 1admin_password: generation 1$ tegata statusadmin_password (manual) generation 1 ADMIN_PASSWORD v1 appmail (value) - MAIL_FROM v1 appsession_key (random) generation 1 SESSION_KEY v1 app PREVIOUS_SESSION_KEY v1 app3. Render
Section titled “3. Render”On a server, render fills the templates from the store. It needs no YAML and no providers:
$ tegata render --store-dir store templates/app outfilled 1 files$ cat out/app.envSESSION_KEY=3f9c…PREVIOUS_SESSION_KEY=3f9c…ADMIN_PASSWORD_SHA256=9c0f…MAIL_FROM=Example <noreply@example.com>out is created with mode 0700 and app.env with 0600.
4. Rotate
Section titled “4. Rotate”$ tegata rotate session_keySESSION_KEY: version 2session_key: generation 2$ tegata render --store-dir store templates/app outfilled 1 files$ tegata settle session_keyPREVIOUS_SESSION_KEY: version 2 (the value of SESSION_KEY)$ tegata prune session_keySESSION_KEY: disabled version 1session_key: pruned generation 1PREVIOUS_SESSION_KEY: disabled version 1Between rotate and settle, a service that accepts both SESSION_KEY and PREVIOUS_SESSION_KEY keeps working with values made before the rotation. Rotating secrets has the steps for every kind of value.
5. Move to Secret Manager
Section titled “5. Move to Secret Manager”-
Replace the store, and set the members of
appto the service account of the server that renders:stores:main:gcp:project: my-projectlocation: us-central1identities:app: [serviceAccount:app-vm@my-project.iam.gserviceaccount.com] -
Run
tegata applywith an account that can administer Secret Manager in the project (yourgcloudlogin is used). -
On the server:
tegata render templates/app /etc/app. On a Compute Engine VM, the project and the credentials come from the VM; elsewhere add--project my-projectand give the server’s identity a way to authenticate.
- Make tokens for other services with providers (
tegata initinstalls them). - Copy secrets to GitHub Actions with destinations.
- Every key and command: the configuration reference and the command reference.