Environment Variables are key-value pairs configured outside your source code so that each value can change depending on the Environment.
Your source code can read these values to change behavior during the Build Step or Launch Cloud Function execution.
All values are visible to any user that has access to the Project. It is safe to use both non-sensitive and sensitive data, such as tokens.
Note: Changes to Environment Variables are not applied to previous deployments. They only apply to new deployments.
You can add environment variables while creating a new project or environment, or configure the environment variables later at Environments > Actions > Settings > Env. Variables.
Add Environment Variables
- Click the project card to open your project from the Launch landing page.
- In the Environments screen, click an existing environment or create a new environment. For this tutorial, we will add an environment variable to the Default environment for the Contentstack API key.
In the Default environment, click the ellipses under Actions and then click Settings to go to the Settings page.
- In Environments under Settings, click Environment Variables.
- In the Add Keys and Values section, click the + Add Environment Variable button to enter the environment variable key and value.
- If you are adding an environment variable for the first time, you can directly add the environment key and value in the respective textboxes.
- You can add up to 100 environment variables per environment.
You can also add or edit environment variables in bulk, in the key-value format, by using the Switch to Editor Mode toggle button. You can add each environment variable in a new line.
An environment variable can be added in the key=value format, or an existing variable's key or value can be edited in the Switch to Editor Mode. The updated environment variables will also be reflected in the Add Keys and Values section.
The bulk edit mode allows you to paste code blocks with key=value pairs, thereby reducing the effort of individually entering environment variables in the key-value edit mode.
- Click the Save button.
If your project is connected to any stack, its status will be available inside Integration Status.
Note: You must trigger a new deployment after adding/modifying environment variables.