Skip to main content

Environment variables

Environment variables are key-value pairs that allow you to configure your application dynamically without modifying code. In Inteleto, environment variables are securely managed and can be accessed within your deployed containers.

Setting Up Environment Variables

You can set and manage environment variables through both the Inteleto Web Console in the Settings tab (in an app). There, you'll be able to add, remove and change any variable. Those variables will be available as operating system environment variables inside the containers of your deployment.

Environment variable

Security and visibility

For security purposes, all environment variables in Inteleto are encrypted in the database and are not visible through the console after they are set. When viewing your environment variables, you'll only see the variable names, not their values.

To manage environment variables:

  • Once set, variable values are preserved until explicitly changed
  • To modify a variable, click the "Change Value" button next to it
  • When you click "Change Value", you can set a new value (the current value is not displayed)
  • If you're updating other variables without clicking "Change Value" on a specific variable, that variable's existing value will be preserved

This approach ensures your sensitive data remains secure while still allowing you to manage your environment variables effectively.

Change environment variables

Accessing the environment variables in your application

When you set an environment variable in Inteleto, it is automatically available inside your container as an operating system environment variable. This means that your application can access these variables using the standard environment variable handling methods provided by the programming language in use.

The exact way to retrieve environment variables varies by language. Below are some common examples:

Updates and restart

Once you change or add a new environment variable, it will be immediately changed in the OS, but since most application will read it once and store it in a global variable, or use the value to create a global object (that won't detect changes in the OS's environment variables), it's generally recommended that you restart the app after making the changes.

Best Practices for Using Environment Variables

  • Environment variables are extremelly recommended in place of storing sensitive credentials in the code. You can use it to store any value, such as API keys, database credentials, and other secrets.
  • Use descriptive variable names. Make sure your variable names are clear and meaningful (e.g., DATABASE_HOST, STRIPE_API_KEY).
  • Use Base64 to encode complex values. If the content of the environment environment is a complex content (with line breaks and indentations, such as a SSL certificate), it's recommended to store its value Base64-encoded. Since the output is just a string, you can set the value to the environment variable, and decode it in your code.
  • Restart your application after changes. For the way most applications are architected, updated variables only take effect when the container restarts.
  • Review the behavior of undefined variables. If an environment variable must be set, add a validation in your code to make sure it is set, or add a default value. This can help you debugging if you forget to set the value for an environment variable, or a new developer with the environment not setup correctly.