The Practical Advantages of ‘Config in the Environment’ for Modern Application Deployment

Alexa Vass
3 min readMar 10, 2023

Let’s dive into the 3rd point of the 12-factor app, which focuses on storing configuration in the environment — config.

A story…

Before diving into the details, let’s start with a story about how the concept of config caught us off guard negatively. While working for a company, we decided to transition from VMs to pre-burned images alongside containers. During the transition process, we decided to move our secrets from files to the parameter store and read them from there in the code. (I thought temporarily.) This seemed like an obvious choice since committing secrets to git is not a safe practice and we didn’t know how to handle them the smart way. However, two team members decided to implement this in the container as well. While this may have been a convenient solution, I strongly disagreed with this move and had many arguments against it.

Photo by Gantas Vaičiulėnas on Unsplash

What’s config

An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc). This includes:
- Resource handles to the database, Memcached, and other backing services
- Credentials to external services such as Amazon S3 or Twitter
- Per-deploy values such as the canonical hostname for the deploy
(https://12factor.net/config)

When it comes to storing config, there are different approaches, including using files or environment variables. While storing config as environment variables or files is not mandatory, using additional files can become cumbersome when working with containers. In earlier times, using files was more common and convenient, but with the increasing popularity of containers, using environment variables has become a more popular and practical approach.

Some developers may suggest using parameter store ARN as a configuration solution, but this can lead to issues when testing locally. Finding a local solution or using the parameter store all the time can be challenging, and it is important to provide developers with easy-to-use tools that streamline the development process. Ultimately, using environment variables is the more straightforward and obvious choice for storing config. By following best practices, developers can efficiently manage config in the environment, leading to greater flexibility and security for their applications.

Why is it good and for whom

The significant advantage of using the “Config in the Environment” principle of the 12-factor app is the positive impact it has on multiple stakeholders in a company.

The development team can benefit from this principle by being able to focus on writing code without worrying about environment-specific configuration. By separating configuration from code, developers can save time and reduce errors, leading to greater productivity.

The operations team can also benefit from this principle by being able to manage configuration separately from the code. This makes it easier to deploy and maintain the application in different environments, reducing the risk of configuration errors and making the application more scalable.

For the security team, this principle helps to reduce the risk of sensitive information (such as passwords and API keys) being accidentally exposed through configuration files. By storing configuration in the environment, access controls can be put in place to secure sensitive information, improving the overall security of the application.

Lastly, business stakeholders can benefit from this principle by having a more stable and scalable application that can be deployed more easily and quickly across different environments. This can lead to increased revenue, decreased costs, and improved customer satisfaction. Additionally, separating configuration from code can help to identify and resolve issues more quickly, reducing downtime and minimizing business disruptions.

All in all,

Following the “Config in the Environment” principle of the 12-factor app can bring significant benefits to different teams within a company, ultimately leading to greater efficiency, security, and customer satisfaction. However, it is important to choose the appropriate implementation.

--

--

Alexa Vass

I am a girl in IT who talks about experiences and loves to learn new things every time, because IT is not my job, it’s my profession.