top of page

Advanced Direnv for Devops

Now you are using Direnv to manage your workspaces, but you stumble upon a difficulty, maybe motivated (like me) by Terraform workspaces.


You have a single codebase for a project, but this codebase needs to be deployed to different environments. Now, we can no longer have a .envrc file in the project's folder, because the environment should be different depending on where we want to deploy. So, how do we solve this? Direnv to the rescue, again.

Using .env's

Direnv has a directive called dotenv, which can be used to load a set of variables dynamically. So in our .direnv file, we can write:

dotenv .env.${ENVIRONMENT}

Then we create two files, and So, each time we enter the directory, the filename of the environment to load is built with the variable $ENVIRONMENT (dev or prod in our case).


Carlos Barroso

Senior MLOps Engineer


Entradas recientes
Buscar por tags
  • Twitter Basic Square
bottom of page