Everything as code
Your version control tool keeps your application’s source code safe by storing all revisions and changes that were done previously. This makes it easy to roll back to a previous state where things worked correctly in the case that a modification puts a release at risk.
It is possible that you are already keeping the structure and data files that form your database in your version control tool as well — so you have in place “database as code”. Storing your schema definition and minimum data in a centralized tool allows your team to deploy several instances easily in an automated, repeatable way. We already talked about versioning your database previously.
Thus, if it’s possible to store your scripts to execute them on demand, what else can we apply this model to?
Defining and scripting your infrastructure could be the next step. Describing the requirements for the machines that will execute your application turns your dedicated fixed server instances into a dynamic environment where machines can be discarded and re-instantiated in minutes. This means that, if a specific configuration is troublesome, there’s no need to open a ticket and wait for someone to fix the mess, blocking your team while this happens. Instead, issues can be detected easily, allowing room to experiment with new values.
Automating your tools grants the chance to try new things. If they don’t work you can discard them, whereas before time had to be invested to fix and roll back modifications.
After “infrastructure as code”, we will talk about “configuration as code”. Since not every environment should answer the same way to certain parameters, these differences must be documented somewhere. Otherwise, you risk to lose this information. Including this description as part of your code makes sense if you are booting virtual machines from file descriptors, as most of these systems already have in place tools to apply variables such as these.
Code, database, infrastructure and configuration as code models allows you to benefit from a fully automated setup for your development teams. This reduces the time necessary for bug fixing, issue solving, and empowers every employee to have full control of the environment they work on.
Originally published at Álvaro G. Cachón.