How to safely deploy environment settings via a config file?

I removed the API credentials and private keys from the project source and repository and now store and apply them from a config file in my local environment.

What's the best way to deploy and apply customizations in my production environment? My first thought was to write a script for:

  • Upload the config file from my local machine to the production server
  • Read config file and apply settings on production server without running settings or exposing them to bash history
  • Delete configuration file from production server

Aside from potentially tracking my internet traffic while loading or disrupting my local machine, is there anything wrong with this approach?

This is a Django project. I use django-environ to read / manage my settings and Fabric to load the config file and run commands remotely during deployment on my server hosted on AWS (I'm not currently interested in using Elastic Beanstalk).

Thank!

+3


source to share


1 answer


how to make it safe

There are millions of ways to make a deployment semi-"secure", but it is extremely difficult (if not impossible) to make it completely secure. The reason is very simple. You need to access sensitive information to run your code. You can obfuscate information as much as you want, but ultimately, if the system is compromised, an attacker can check the running processes, therefore, extract all confidential information.

As I said, I don't see anything fundamentally wrong with using a config file to launch your application if you follow all of the standard deployment methods, such as using another non-root user to launch your application, etc.

the best way to deploy



I think 12 factors of redesigned apps are considered best practice in the industry. The third rule says that you must customize your applications:

Save configuration in environment

Storing configuration in env variables makes it easy to deploy the same application to many environments without changing your code. Doing this may not be 100% safe, but I think if you are taking any of the usual precautions like running the server as a different user, etc., you should be fine in most cases.

Obviously, it all depends on the type of your application. If your application is dealing with super sensitive data, I would suggest exploring other methods for deploying applications in highly secure environments. This, however, is perhaps outside the scope of your question and outside of my area of ​​expertise, so maybe other smart people here on SO can help.

0


source







All Articles