On this page

Environment Variables

Environment variables let you configure your application without changing the code. Use them to store database URLs, API keys, runtime settings, and other values that may vary between environments.

Managing environment variables

Adding variables

  1. Go to the service page in the dashboard
  2. Navigate to the Environment Variables tab
  3. Click Add Variable
  4. Enter the name (key) and the value
  5. Click Save

You can add as many variables as you need. Each variable is injected as an environment variable into your application’s container.

Editing variables

To edit an existing variable, click the edit icon next to it, change the value, and save. The previous value will no longer be accessible after editing.

Removing variables

To remove a variable, click the delete icon and confirm the action. The variable will be removed from the container on the next deployment.

Secret masking

Sensitive values are automatically masked in the dashboard after being saved. This means that after you set a variable, the full value will no longer be displayed in the interface. You can replace the value at any time, but you cannot view the current value.

This protects secrets like API keys and database passwords from accidental exposure.

Common patterns

Here are some commonly used environment variables:

VariableExampleUsage
DATABASE_URLpostgresql://user:pass@host:5432/dbDatabase connection
API_KEYsk-abc123def456External service API key
NODE_ENVproductionRuntime environment (Node.js)
PORT3000Application port
SECRET_KEYmy-secret-keyEncryption/token key

Platform-injected variables

Guara Cloud automatically injects a set of environment variables into every service. You do not need to create these manually.

VariableExampleDescription
PORT3000The port your service should listen on
GUARA_SERVICE_NAMEmy-api-a3f2c1The service slug (internal identifier)
GUARA_PROJECT_NAMEmy-projectThe project slug
GUARA_ENVIRONMENTproductionThe runtime environment

Service discovery variables

When your project has multiple services, Guara Cloud automatically injects environment variables so each service can discover and communicate with its siblings. These variables use the service name as a prefix, making them intuitive and predictable.

For each sibling service, three variables are injected:

VariableFormatDescription
{SERVICE_NAME}_HOST{slug}.{namespace}.svc.cluster.localInternal hostname of the sibling
{SERVICE_NAME}_PORT3000Port the sibling listens on
{SERVICE_NAME}_URLhttp://{slug}.{namespace}.svc.cluster.local:3000Full URL to reach the sibling

The {SERVICE_NAME} prefix is derived from the sibling’s name: uppercased, with spaces and hyphens replaced by underscores.

Example

Suppose your project has three services:

  • My API (port 8080)
  • My Worker (port 3000)
  • Redis Cache (port 6379)

The My API service will automatically receive:

# Discovery vars for "My Worker"
MY_WORKER_HOST=my-worker-b4d3e2.proj-myapp.svc.cluster.local
MY_WORKER_PORT=3000
MY_WORKER_URL=http://my-worker-b4d3e2.proj-myapp.svc.cluster.local:3000

# Discovery vars for "Redis Cache"
REDIS_CACHE_HOST=redis-cache-c5e6f7.proj-myapp.svc.cluster.local
REDIS_CACHE_PORT=6379
REDIS_CACHE_URL=http://redis-cache-c5e6f7.proj-myapp.svc.cluster.local:6379

You can use these variables directly in your application code:

// Node.js example
const workerUrl = process.env.MY_WORKER_URL;
const response = await fetch(`${workerUrl}/tasks`);
# Python example
import os
worker_url = os.environ["MY_WORKER_URL"]

Best practices

  • Never put secrets in source code. Use environment variables to store sensitive values.
  • Use descriptive names. Prefer DATABASE_URL over DB for easier maintenance.
  • Separate by environment. Use different values for development and production.
  • Review periodically. Remove variables that are no longer in use.