Skip to main content

Step 5: Create runtime environment variables

Every running application requires environment-specific runtime values to function properly. These values could include secret keys for third-party services, boolean flags enabling features, and much more.

To manage these variables, the ShipFast leverages AWS Systems Manager Parameter Store and a tool called chamber. With these tools, managing environment variables is easy and secure.

caution

Before deploying your application's code, you must set all required environmental variables!

Install chamber CLI tool

Follow the official instructions on how to install chamber.

Switch context to proper environment stage

Run the following command that will switch context to specific environment stage.

saas aws set-env [STAGE_NAME]

How does it work?

Using the CLI tool

You can then set the environment variables for the service (such as backend) in JSON format using the CLI command

Backend:

pnpm shipfast backend secrets

Webapp:

pnpm shipfast webapp secrets

Workers:

pnpm shipfast workers secrets

This will download a JSON secrets file, open it in Vim, and re-upload it when you save the file.

Manually using the AWS console

Alternatively, you can set your environment variables manually by going to the AWS console and adding or editing the parameters in the Systems Manager > Parameter Store section.

Note that the Name of every parameter should follow this naming convention:

/env-<PROJECT_NAME>-<STAGE_NAME>-<SERVICE_NAME>/<ENVIRONMENT_VARIABLE_NAME>

in order to be correctly loaded into

Set env variables for backend

pnpm shipfast backend secrets

Required variables:

NameDescriptionExample
DJANGO_DEBUGdocsTrue
DJANGO_SECRET_KEYdocsZs639zRcb5!9om2@tW2H6XG#Znj^TB^I
HASHID_FIELD_SALTdocst5$^r\*xsMRXn1xjzhRSl8I5Hb3BUW$4U
ADMIN_EMAILWill be used to create first super admin user[email protected]
ADMIN_DEFAULT_PASSWORDWill be used to create first super admin userAvPZpabgj9Z8

Check the api reference for full list of backend env vars.

Set env variables for workers

pnpm shipfast workers secrets

Required variables:

NameDescriptionExample
FROM_EMAILEmail used in From email field[email protected]
HASHID_SALTdocst5$^r\*xsMRXn1xjzhRSl8I5Hb3BUW$4U
JWT_SECRETSecret used to decode JWT used in subscriptions. The value needs to be the same as DJANGO_SECRET_KEY backend environment variable
WEB_APP_URLhttps://app.demo.saas.apptoku.com

Check the api reference for full list of workers env vars.

Set env variables for web app

pnpm shipfast webapp secrets

Required variables:

NameDescriptionExample
VITE_BASE_API_URLPath to access backend API/api
WEB_APP_URL
VITE_EMAIL_ASSETS_URLAbsolute URL to applicationhttps://example.com

Check the api reference for full list of web app env vars.