Technology

Infrastructure as Code for Small SaaS Teams: Bicep vs Terraform

You do not need a platform team to benefit from infrastructure as code. You need one afternoon and a bit of discipline. Here is how I would start.

Infrastructure as Code for Small SaaS Teams: Bicep vs Terraform

Infrastructure as code for small SaaS teams sounds like something that belongs in a company with a platform team and a budget for conference tickets. It does not. If you have ever rebuilt a production environment from memory while a customer waited, you already know why it matters.

I have been bitten by this more than once. A setting changed in the Azure portal six months ago, nobody wrote it down, and then staging behaved differently to production for reasons nobody could explain. That is the problem infrastructure as code solves, and it is a boring, practical solution.

What infrastructure as code actually means

It means your servers, databases, networking and app settings are described in text files that live in your repository. You run a tool, and the cloud matches the files. If you want a new environment, you run it again with different parameters.

That is it. No magic. The value is not cleverness, it is that your infrastructure now has a history, a review process and a way of being rebuilt on a bad day.

Why small teams need it more than big ones

Big companies have people who remember how things were set up. Small teams have one developer who set it up two years ago and has since forgotten half of it. That developer is often me.

When you are small, you cannot afford a week of downtime because the one person who understood the setup is on holiday in the motorhome with patchy signal. Writing it down as code is the cheapest insurance you will ever buy.

The three things it gives you straight away

First, repeatable environments. Dev, test and production stop drifting apart because they come from the same files.

Second, a safe way to review changes. A pull request showing that a database tier is changing is far better than someone quietly clicking a dropdown.

Third, disaster recovery that is more than a hope. If you want to see how this fits into a wider plan, I wrote about it in my guide to disaster recovery for small SaaS businesses.

Bicep vs Terraform: which should you pick?

This is the question everyone asks, and the honest answer is that either will do the job. The right choice depends on where you live.

Choose Bicep if you are all in on Azure

Bicep is the Microsoft language for Azure resources. It is clean, readable, and has no state file to look after because Azure itself is the source of truth. New Azure features usually show up in Bicep very quickly.

If you are a .NET shop on Azure, which describes most of what I build, Bicep is the path of least resistance. Your team will pick it up in a day.

Choose Terraform if you are multi cloud or use lots of third party services

Terraform works across Azure, AWS, Cloudflare, GitHub and hundreds of other providers. If you want your DNS, your monitoring and your cloud resources in one place, that is a real advantage.

The cost is the state file. It has to be stored somewhere safe, locked properly, and never edited by hand. Small teams get this wrong more often than they admit.

My honest recommendation

If you are only on Azure, use Bicep and stop worrying. If you genuinely spread across providers, use Terraform and take the state file seriously from day one. Do not spend three weeks comparing them. That time is better spent writing the first template.

A sensible way to start without a big rewrite

The mistake I see is people trying to convert their entire estate in one go. That is how infrastructure as code projects die in a half finished branch.

Start with the pieces that hurt most. Here is the order I would use.

Step one: describe what you already have

Pick one resource group or one environment and write templates that match what is already running. Most tools can export the current state to get you moving. Clean it up, but do not redesign anything yet.

Step two: deploy through your pipeline

Once the templates exist, run them from your build pipeline rather than your laptop. This is where it starts paying off, because nobody can change production without it going through the same route as code. If your pipeline is not in good shape yet, my post on CI/CD pipelines for small teams covers what matters.

Step three: lock the portal down

This is the bit people skip. If everyone can still change things by hand in the portal, your code slowly becomes fiction. Make the portal read only for most people and keep one break glass account for emergencies.

Common mistakes with infrastructure as code

The first is putting secrets in the templates. Use Key Vault references and pass secrets in at deploy time. Never commit a connection string, even to a private repo.

The second is building clever abstractions too early. Three copies of a similar template is fine. A custom module system with its own documentation is a project you will regret maintaining.

The third is having no way to preview changes. Both Bicep and Terraform can show you what will change before it happens. Use that on every pull request. It has saved me from deleting a database more than once.

What it costs and what you get back

The cost is a few days of learning and some discipline. The return is a calmer life. New environments take minutes, changes are reviewed, and the "who touched that setting" arguments disappear.

It also makes your cloud bill easier to reason about, because everything that exists is written down. If that is a worry for you, have a look at how to keep your Azure bill under control.

If you want a second pair of eyes on your setup, or help getting the first templates in place, that is the kind of work I do through my development and consulting services. Otherwise, pick one resource group this week and start there. You will wish you had done it sooner.

More from the blog

Technology•6 min read

Azure App Service vs Containers for Small SaaS Teams

Read more
Technology•6 min read

Secrets Management for Small SaaS Teams: A Practical Guide

Read more
Business•8 min read

Five Things I Learned Bootstrapping Five Businesses

Read more