Loading .env file in hook

I’m very new to Ruby and am looking for some guidance…

I would like to have a .env file in my project’s root directory that holds my various Azure configuration (tenant, subscription, etc), but I can’t figure out how to get it to work.

I’ve added dotenv to my Gemfile and ran bundle, but I don’t know how to go about using it in a hook.

Can anyone help me? Thanks in advance.

Been meaning to add dotenv support. Went ahead and added it. https://github.com/boltops-tools/terraspace/pull/189

To answer your question, though, would had used a config/boot.rb hook and ran code like so:

But it’s been added to Terraspace now so you don’t have to do that.

Terraspace docs https://terraspace.cloud/docs/config/dotenv/

Hi Tung… That’s awesome, thanks!

One small issue, though. I’ve installed terraspace via the rpm repository, and this morning when I updated my system I saw the following:

  Running scriptlet: terraspace-1.0.1-1.amazon2.x86_64                    34/86 
You're about to install terraspace!

  Upgrading        : terraspace-1.0.1-1.amazon2.x86_64                    34/86 
  Running scriptlet: terraspace-1.0.1-1.amazon2.x86_64                    34/86 
Thank you for installing terraspace!

Terraspace has been installed. You can check by running:

    terraspace version

You should see the terraspace version.
If you do not see this, it may be that /usr/local/bin is not in your PATH yet.
You can adjust ~/.bash_profile and add:

    export PATH=/usr/local/bin:$PATH

And open a new terminal

  Running scriptlet: terraspace-1.0.0-1.amazon2.x86_64                    58/86 
terraspace has been uninstalled!

And indeed, I can no longer run the terraspace command.

Strangely, if I try to install it again, dnf tells me it is already installed.

Uninstalling, then reinstalling fixed that issue for me.

Oh that is interesting. It’s an issue with the standalone installers and updating. Will take a look. Thanks for the report.

The standalone installers no longer clean up the wrapper scripts, which is what is causing the specific issue when you updated.

Update docs to reflect this: https://terraspace.cloud/docs/install/standalone/details/uninstall/

1 Like