Skip to content

Environment Variables

When building an API application you will have to deal with different kind of environments and secrets. In APICHAP this is solved by environment variables using the ENV() method. The use of environment variables will help to keep sensitive data like passwords and API keys out of your configuration files. By using the ENV() method, you can reference either environment variables defined in your APICHAP config files or system environment variables.

Defining Environment Variables in the Config:

You can define environment variables using the environment section in any of your config files. For example:

environment:
  FTP_PASSWORD: pwd

Creating a .environment.yaml file that you replace for each environment could therefore be a good way to handle different values.

Using System Environment Variables:

In addition to the environment section in your config files, APICHAP also supports accessing system environment variables. This allows you to manage secrets using your existing infrastructure, such as Docker, Kubernetes, Azure, or any other platform that supports environment variables.

Usage:

```yaml datasources: myftp: type: ftp host: The ftp hostname port: 21 user: The ftp user password: ${ENV(FTP_PASSWORD)} '''