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.
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:
Name | Description | Example |
---|---|---|
DJANGO_DEBUG | docs | True |
DJANGO_SECRET_KEY | docs | Zs639zRcb5!9om2@tW2H6XG#Znj^TB^I |
HASHID_FIELD_SALT | docs | t5$^r\*xsMRXn1xjzhRSl8I5Hb3BUW$4U |
ADMIN_EMAIL | Will be used to create first super admin user | [email protected] |
ADMIN_DEFAULT_PASSWORD | Will be used to create first super admin user | AvPZpabgj9Z8 |
Check the api reference for full list of backend env vars.
Set env variables for workers
pnpm shipfast workers secrets
Required variables:
Name | Description | Example |
---|---|---|
FROM_EMAIL | Email used in From email field | [email protected] |
HASHID_SALT | docs | t5$^r\*xsMRXn1xjzhRSl8I5Hb3BUW$4U |
JWT_SECRET | Secret used to decode JWT used in subscriptions. The value needs to be the same as DJANGO_SECRET_KEY backend environment variable | |
WEB_APP_URL | https://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:
Name | Description | Example |
---|---|---|
VITE_BASE_API_URL | Path to access backend API | /api |
WEB_APP_URL | ||
VITE_EMAIL_ASSETS_URL | Absolute URL to application | https://example.com |
Check the api reference for full list of web app env vars.