Getting our configuration from environment variables
So far, we have been loading configuration variables from YML files. This has a few issues. First, we must move these files around where our deployment is. Also, files do not work efficiently with orchestration tools such as Kubernetes. Kubernetes uses ConfigMaps, which essentially define environment variables for each container they are running. Environment variables also work well with tools such as Secret Manager and AWS credentials. We can also directly overwrite the environment variables in docker-compose
. With all these advantages in mind, we will switch our configuration values from files to environment variables. To map where we have implemented configuration variables from a file, all we must do is delete our src/config.rs
file and the module declaration of that config
module in the main.rs
file. Then, we can run the cargo test
command again to get the following output:
--> src/database.rs:12:12 ...