Skip to main content
Get a list of all variables defined on a given environment in the Console or use the CLI:
You get output similar to the following:

Access variables in a shell

Project and environment variables with the prefix env: are available as Unix environment variables in all caps. Access these variables and Upsun-provided variables directly like this:
Other project and environment variables are listed together in the PLATFORM_VARIABLES variable as a base64-encoded JSON object. Access them like this:
You can also get the value for a single variable within the array, such as with this command, which uses the jq processor:
Variable availability depends on the type and configuration. Variables available during builds can be accessed in build hooks and those available at runtime can be accessed in deploy hooks.

Access variables in your app

To access environment variables in your app, use a built-in method for the given language.

Access complex values

Variables can have nested structures. The following example shows nested structures in an app configuration: You can access these nested variables as follows:

Use provided variables

Upsun also provides a series of variables to inform your app about its runtime configuration. Many of them have a PLATFORM_ prefix to differentiate them from user-provided values. You can’t set or update them directly. The following table presents all available variables and whether they’re available at build time (during build hooks) and at runtime.

PLATFORM_APPLICATION

The PLATFORM_APPLICATION variable is available both at build time and in the runtime environment. But the specific attributes it contains differ in each case. Each environment’s build is associated with a configuration ID that identifies it uniquely so builds can be reused. The ID is a product of your app code and some of its configuration for Upsun. Not every attribute your app configuration is relevant to the build. Only those attributes that are relevant to builds are accessible at build time from PLATFORM_APPLICATION. Attributes that are not available in PLATFORM_APPLICATION during builds:
  • Everything under access
  • Everything under relationship
  • hooks.deploy and hooks.post_deploy
  • Everything under crons
  • Everything under web, except web.mounts
  • Everything under workers, except workers.mounts
These attributes aren’t visible during build because they aren’t included as a part of the configuration component of the build slug. So modifying these values in your app configuration doesn’t trigger an app rebuild, only a redeploy. For more information, read about how builds work.

Use variables in static files

Some apps require configuration values to be specified in a static, non-executable file (such as a .ini, .xml, or .yaml file) and don’t support reading from environment variables. To populate these files with variables you set yourself, make sure the variables are set to be visible at build time. The files can’t be populated with Upsun-provided variables not available at build time (such as PLATFORM_RELATIONSHIPS or service environment variables). You also can’t write to them in a deploy hook as the file system is read only. One workaround is to create a symbolic link to a writable location and then write to it in a deploy hook. The following example shows the process, though you have to modify it to fit your needs.
  1. Create a mount that isn’t accessible to the web in your app configuration:
  1. Create a symbolic link from the config file the application wants to a location in that mount:
    This example assumes the app wants a db.yaml file in its root for configuration.
  2. Commit the symbolic link and an empty config directory to Git.
  3. Configure a script to read from environment variables and write to config/db.yaml through the service environment variables themselves, or through the PLATFORM_RELATIONSHIPS environment variable.
    Create a file with a shell script similar to this:
export-config.sh
  1. Call the script from the deploy hook your app configuration:
Now, when your app starts and attempts to parse db.yaml, the symbolic link redirects it to config/db.yaml. Your script writes to that file on each deploy with updated information. Your app reads the exported values and proceeds as expected.
Last modified on March 18, 2026