Skip to Content

Store secrets

Keep API keys and passwords out of your code and hand them to apps as variables or files.

Goal: a secret, such as a payment provider's API key, stored once and given to one or more apps as an environment variable or a file.

Before you start

  • An environment with at least one app that needs the secret.
  • The secret value, or a plan to let A-Line.cloud generate one.

Create a secret

Console

Open Secrets in the sidebar. The Managed Secrets tab lists the secrets of the environment.

Select Create secret. The Create Environment Secret dialog opens.

Enter a Key, such as STRIPE_API_KEY, and an optional Description.

Paste the Value, or turn on Generate a random value for a password the app creates its own account with.

Turn on Write-only if nobody should read the value back after you save it. Apps still get it.

Pick the Injection Mode: Env Var, File Mount or Both. For a file, set the Mount Path.

Select Create Secret.

IaC

IaC files hold the keys, never the values. Declare the key in a secret group, then set its value in the console or through the API:

secrets/payments.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
environment: production
description: Payment provider keys
keys:
  STRIPE_API_KEY: {write_only: true}

API

Create the secret in the environment. The value is write-only in the API: it is never returned.

POST /v1/environments/{environment_id}/secrets
Authorization: Bearer $ALC_API_KEY
Content-Type: application/json

{ "name": "STRIPE_API_KEY", "value": "sk_test_example", "injection_mode": "env", "write_only": true }

See Secrets for setting a new value later.

MCP

Ask your connected client to create the secret, for example: "Create the secret STRIPE_API_KEY in production." Its set_secret tool creates it and refuses a name that already exists, so a retry never overwrites a value. Paste values only into clients you trust with them. See Connect an AI client.

Give it to an app

Open the app on the project canvas and go to its Env Vars tab.

Select Add from Secrets and pick the secret.

Deploy the app. The new value is used from the next deploy.

Share secrets with a group

A secret group bundles secrets that belong together, such as all credentials of one service, and links them to several apps at once.

On the Secret Groups tab, select New group, enter a name and select Create group.

In the group, select Add existing to add secrets.

Select Link an app... to give every secret in the group to an app.

Changes to a group show Restarts on next deploy for the apps that use it: they get the new values on their next deploy.

Verify

  • The secret is listed on the Managed Secrets tab. Open it to see its versions and the apps that use it.
  • After a deploy, the app's Logs show it starting without a missing variable error.

Troubleshooting

  • The app still has the old value: values are read when a pod starts. Deploy the app again.
  • The secret is not offered in Add from Secrets: secrets belong to one environment. Check that the app runs in the same environment.
  • You cannot see the value: the secret is Write-only. Set a new value instead.

Database credentials

Do not store database passwords as secrets. Use a definition instead: each pod then gets its own short-lived login. See Add a database and connect an app. Short-lived credentials are listed on the Dynamic Leases tab.

In IaC

A secret group is a file secrets/<group>.yaml that lists the keys, never the values. Apps name the groups they use under secrets. See Secrets in IaC and using a group.

Next steps

On this page