Project Environment Variables

Environment Variables

You can configure environment variables both for projects and globally on the Platform. These key-value pairs are kept in encrypted storage and injected into your analysis at runtime. The primary purpose of this feature is to help you avoid checking sensitive information (like a database password) into your Git repo.

You can use these environment variables like you would in any other analysis. For example, if you create an environment variable on the Platform with key REDSHIFT_PASSWORD and value im_secure, you can run the following example in Python:

import os
print os.environ['REDSHIFT_PASSWORD']
>>> im_secure

There are a few rules to remember when using environment variables:

  • Environment variables are injected once into your analysis when you launch it. You must shut down and re-launch any analyses to access new variables.
  • If you need to edit an existing environment variable, you must delete it and create a new one.
  • If a global environment variable and a project environment variable share the same key, the project environment variable will take precedence.

Project Environment Variables

If you have Own or Edit permission, you can add and remove project environment variables. You can find project environment variables on the project Settings tab under Environment Variables. Remember that if you have a global and project environment variable with the same name, only the global variable will be available in your analysis.

../_images/Project-environment-variables.png

For information on Global Environment Variables, see our Account Setup documentation.