Set config and secrets
Declare the keys your service reads, set a value for each environment, and know when a change reaches the running service. Config never lives in the image.
What happens in the cloud
putnami publishregisters the config schema of your project: its declared keys.- The same publish pushes the values of
conf/env.<env>.yaml. The platform pins these non-secret values in the release set. - At deploy time the platform resolves the config of the new revision from what the release pins. The service reads it as declared.
- Secrets are never pinned. The service resolves them when an instance starts.
- Idle services scale to zero, so a new instance starts on the first request after idle. It reads the current secrets then.
Do it
Declare the keys
Declare config keys in the config schema of the project. The publish step reads the schema/config.json artifact. The workload also declares a @putnami/cloud:publish-config namespace in its putnami.json.
Set values
Put non-secret values in conf/env.<env>.yaml, one file per environment. A merge to main publishes them with the release set.
To write values from a YAML file without a release:
putnami cloud config put <project> --env prod --config-from conf/env.prod.yamlAdd --dry-run to see the planned writes. The platform checks each value against the schema before it writes.
Set a secret
putnami cloud secrets set <project> <key> --env prod --from-stdinPass the value with --from-stdin, --from-file <path> or --value. Prefer stdin: a value on the command line stays in your shell history.
| Want to… | Do this |
|---|---|
| List secrets | putnami cloud secrets list <project> --env prod |
| Delete a secret | putnami cloud secrets delete <project> <key> --env prod |
| Print a secret in plaintext | putnami cloud secrets reveal <project> [<key>] --env prod |
| Check which secrets are set | putnami cloud secrets status [<project>] |
Read what the service resolves
putnami cloud config show <project> --env prod| Want to… | Do this |
|---|---|
| Read one key | putnami cloud config show <project> --env prod --key <key> |
| List declared keys and whether each is set | putnami cloud config show <project> --env prod --declared |
| Print the published schema | putnami cloud config show <project> --env prod --schema |
| List the secret keys, set or missing | putnami cloud config show <project> --env prod --secret-keys |
| Print the secrets as redacted | putnami cloud config show <project> --env prod --with-secrets |
| Print the secrets in plaintext, after you confirm | putnami cloud config show <project> --env prod --reveal-secrets |
| Check the local files offline | putnami cloud config validate <project> --env prod |
| Compare local files with what is published | putnami cloud config drift <project> |
putnami cloud config alone prints help. Always name a verb.
When a change reaches the service
| You change | It reaches the service |
|---|---|
| A non-secret value | At the next deploy. A config write rolls no revision. |
| A secret | When an instance starts. New instances read the new value without a deploy. |
What you see
putnami cloud config status <project> compares the declared keys with what each environment sets. It exits 1 when a required key has no value and no default:
config shop/workloads/api failing 1 required key missing
METRIC VALUE WINDOW
keys declared 12 now
keys set 11 of 12 (92%) now
required missing 1 now
optional missing 0 now
STATE CHECK DETAIL
failing prod 1 required key missing: stripe.endpoint
fix: putnami cloud config publish shop/workloads/api --env prod
failing stripe.endpoint required, no value and no defaultA key that resolves to its schema default counts as set. putnami cloud secrets status <project> does the same for secrets. It never reads a value.
When it fails
| You see | Cause | Fix |
|---|---|---|
required key missing |
A key has no value and no default in the environment. | Add it to conf/env.<env>.yaml and merge, or run config put. |
required secret missing |
A secret is not set in the environment. | Run putnami cloud secrets set <project> <key> --env <env> --from-stdin. |
config put refuses a file |
The file still holds a placeholder marker, or no value matches a key of the schema. | Edit the file. Run again with --dry-run. |
| A new value does not show in the service | A non-secret value waits for the next deploy. | Merge a change, or wait for the next channel move. |