Skip to main content

Overview

Environment variables are used to configure your agent without hardcoding sensitive information. RunAgent provides secure methods for managing environment variables across development and production.

Local Development

Using .env Files

Create a .env file in your project root:
Load in your agent:

Best Practices

  1. Never commit .env files
  2. Provide .env.example
  3. Validate required variables

Configuration in runagent.config.json

Dynamic Substitution

Use ${VAR_NAME} syntax for runtime substitution:

Variable Types

  1. Dynamic variables - Loaded from environment
  2. Static values - Hardcoded (non-sensitive only)
  3. With defaults (coming soon)

Production Deployment

Setting Variables

When deploying, set environment variables:

Security Best Practices

  1. Use secret management services
    • AWS Secrets Manager
    • Google Secret Manager
    • Azure Key Vault
    • HashiCorp Vault
  2. Rotate keys regularly
    • Set expiration reminders
    • Use versioned secrets
    • Update without downtime
  3. Limit scope
    • Use read-only credentials where possible
    • Create service-specific API keys
    • Apply principle of least privilege

Common Patterns

Configuration Classes

Environment-Specific Settings

Validation

Special Variables

RunAgent System Variables

Framework-Specific

Troubleshooting

Variable Not Found

Loading Order

  1. System environment variables
  2. .env file (local development)
  3. RunAgent configuration (deployment)
  4. Runtime overrides

Common Issues

  1. Quotes in .env files
  2. Spaces around equals
  3. Multiline values

See Also