What are Environment Variables?

Find out everything you need to know about Environment Variables

The Crowdbotics Dashboard allows you to customize what are called "Environment Variables." As this will impact your app, we hope you familiarize yourself with these and learn how to work with them.

Environment Variables affect the environment in which the app runs by making their values available to the code during execution.

Suppose you set up a Twilio account for your app. You have two levels of access: sandbox and production. In development you want to use the sandbox, and in production you want to use the production. These two levels have different endpoints and different keys. You decide you’ll store the key inside TWILIO_ACCESS_KEY env var. You define this env var locally on your development machine (this is done either by using the .env file, or by setting an actual env var in your shell) and assign it the value of a sandbox key.

In production, you define the same var and assign it a value of a production key. In your custom code snippet for Twilio, you obtain the value of this variable dynamically during code execution by using the built-in function of a language/framework you’re using for development.

When a project is first created, the "GITHUB_SECRET" Environment Variable is created by default.

You can view and access your Env Vars from your App Dashboard, but you cannot manage or add new variables until you successfully deploy.

When you first deploy your build, Crowdbotics creates a Heroku deployment pipeline with a Heroku app attached, provisions Postgres, Redis, and Papertrail for that app, and it creates a domain name for your app.

Anything that can change based on deployment, any keys, passwords, secrets, etc. should always be stored inside the environment and the code should always obtain those from the environment.

The vars you see in the dashboard are good examples of such information, and should always be referenced for security and portability. Any good web developer will be right at home: the code contains enough information inside the README files to answer most questions.