Secrets are secure pieces of data you can store and use at runtime, such as API keys, database passwords, or plaintext values. These are made available to your project as environment variables for use as needed.
Caution
Secrets are encrypted before being stored in the database. However, due to the nature of Serverize,avoid storing sensitive production data (e.g., production database connection strings or API keys) as secrets.
How Secrets Work
Serverize assigns secrets to channels, making them accessible to any release made under those channels.
Setting Secrets
To set secrets for a channel, use the secrets set
command along with the project name flag and channel.
npx serverize secrets set NAME=VALUE NAME=VALUE -p <project-name> -c <channel-name>
Example: set single secret
npx serverize secrets set API_KEY=12345 DB_PASSWORD=secret -p my-project -c dev
This command sets the API_KEY
secret to 12345
for channel dev.
Note
if channel not specified then it defaults to “dev”
Example: set multiple secrets
npx serverize secrets set API_KEY=12345 DB_PASSWORD=secret -p my-project
This command sets the API_KEY
and DB_PASSWORD
secrets for the project my-project
.
Setting Secrets from a File
You can also set secrets from a file, such as an .env
file, using the secrets set-file
command.
npx serverize secrets set-file <path-to-env-file> -p <project-name> -c preview
Example:
npx serverize secrets set-file .env -p my-project -c preview
This command reads the .env
file and sets all the environment variables as secrets for the project my-project
and channel dev
Note
Ensure that your
.env
file is properly formatted withKEY=VALUE
pairs, each on a new line.
List Secrets
List secrets labels that are set for your project channel.
npx serverize secrets list -p <project-name> -c <channel-name>