How do I set up environment variables outside of the git repo?

Hi there,

I’m new to this forum and to middleman, so expect obvious newbie mistakes from me.

I’d like to host a middleman-based statis site on AWS. I’ve read the docs. All the solutions on that page involve writing down the access keys inside config.rb.

But I also want to make the source code of my website available to everyone. So instead of having the keys inside config.rb, I’d like to have them somewhere else; probably in system variables, so I can do ENV['AWS_ACCESS_KEY']. Ideally, I would like to keep them in a local .gitignored file.

How does one do that (or something equivalent) in middleman?

Have you heard of Dotenv? I find it to be the easiest way to have local ENV variables in Ruby projects (that can be .gitignored) I decided that I couldn’t resist wrapping it up in an extension so feel free to check it out.

Also, keep the questions coming. No question is too obvious :smile:

1 Like

Wow - Wow! You blew my mind! Twice!

I didn’t know about Dotenv, but I will certainly add it to my arsenal. The fact that you have created a middleman plugin for it in such short time is amazing.

I have been able to store the credentials in the .env file, and ignored the whole thing. Worked perfectly well, thank you so much!

P.S.: I don’t know if you are able to do so, but now that middleman-dotenv exists, it should make sense to add a reference to it on the Deployment solutions page