Environment Variables

Ryan Rich -

Environent Variables

How do Variables Work?

Variables in The Platform are set or reset for a code service every time the service is built or redeployed. These variables contain data that the code service can then consume as environment variables during operation. Variables are specific to a single code service.

Why Are Variables Important?

Variables in The Platform allow an application to consume information that is not appropriate for storing in a code repository. That type of data could include:

  • Third-Party Service Credentials
  • Dynamic Configuration Settings

Pre-Defined Variables

Each new code service comes with several pre-defined variables that contain important information for your application to function and vary depending on the services in your environment. You can view these in [The Platform Dashboard][https://product.datica.com/environments] on your code service as soon as your environment is created by Datica. Examples include:

  • DATABASE_URL
  • S3_BUCKET
  • REDIS_URL

Before you make your first code deploy, make sure that your application is ready to consume these values! First, click on the “View Details” link for the code service.

dashboard_view_details-b76e470d.png

The service’s variables are located here:

dashboard_env_variables-2661ec28.png

Setting Your Own Variables

To set your own variables, check out our variable management guide located here.

Managing Variables

The Platform allows you to define as many variables as you want for each different code service. You can manage variables through the Datica CLI.

List variables via the CLI

Below is an example command and the type of output you can expect to see:

datica -E Prod-app01 vars list app01

Sample Output:

CACHE01_URL=redis://cache01.internal:6379
DATABASE_URL=postgres://catalyze:1234567890@db01-01.internal:5432/catalyzeDB
PORT=8080
REDIS_URL=redis://cache01.internal:6379

Set variables via the CLI

Below is an example command:

datica -E Prod-app01 vars set app01 -v ENV_VAR1="MYVALUE1" -v ENV_VAR2="MYVALUE2"

For the new variable settings to take effect, you will need to redeploy your service.

datica -E Prod-app01 redeploy app01

Unset variables via the CLI

Below is an example command and the type of output you can expect to see:

datica -E Prod-app01 vars unset app01 -v ENV_VAR1

Sample Output:

Unset.

For the new variable settings to take effect, you will need to redeploy your service.

datica -E Prod-app01 redeploy app01