Cloud · · 6 min read

If it is not in code, it does not exist.

Clicking through a cloud console is the fastest way to build an environment and the slowest way to run a company. The case for infrastructure as code, and how to adopt it without stopping the world.

By Precision Code Studios, Engineering team

Every cloud platform has a friendly web console, and every team starts there. Need a database? A few clicks. A network rule? A few more. It is quick and it works, and a year later the company's entire production environment exists as the accumulated result of several hundred undocumented clicks made by people who have since moved teams.

Then something goes wrong. A region has an outage, or a customer needs a separate environment, or an auditor asks who opened that port. And nobody can say with confidence how the system is put together, let alone build it again.

What infrastructure as code means

The idea is simple. Instead of creating servers, databases and networks by hand, you describe them in files: this application, three copies, this size; this database, with backups; this network, only these doors open. A tool reads the description and makes reality match it. The files live in version control beside the application code and change the same way, through review. Terraform and OpenTofu, Pulumi, Azure's Bicep and AWS CloudFormation are the common choices.

Two pairs of environments: set up by hand they differ in four settings, defined in code they are identical
Drift is invisible until the day it causes an outage.

What you gain

  • Environments that match. Staging behaves like production because both come from the same definition.
  • A history of every change. Who changed what, when, and why, with the ability to go back.
  • Review before impact. The tool shows exactly what will be created, altered or destroyed before anything happens.
  • Recovery you can rehearse. Rebuilding everything in a new region becomes a command, not a month.
  • Security you can inspect. Rules written down can be checked automatically. Rules clicked into place cannot.
  • New environments on demand. A copy for a large customer, a demo or a test is the same code with different settings.

Where teams go wrong

The tool keeps a record of what it has built, and that record often contains sensitive values. Store it securely and never in the repository. Avoid one enormous definition for the whole company: a mistake in it can touch everything at once, so split it along the lines your teams and systems already follow. And resist cleverness. Infrastructure code is read in a hurry, during incidents, by people who did not write it. Plain beats elegant.

Adopting it without a rewrite

  • Start with what is new. The next service or environment is built from code from its first day.
  • Import what matters most. Existing resources can be brought under management without recreating them. Begin with the network and the databases.
  • Put it in the pipeline. Changes are proposed, reviewed and applied by automation, not from a laptop.
  • Close the console. Read-only access for people, write access for the pipeline.

The return is not really speed, though you get that too. It is confidence: the knowledge that your systems are what the code says they are, that you could build them again tomorrow, and that the next change will not be a surprise.

Keep reading

All insights