Cloud & Infrastructure

Infrastructure as Code (Pulumi)

Intermediate

Infrastructure built by hand in a portal is undocumented, hard to reproduce, and impossible to review. Nobody fully understands it until it breaks. Defining infrastructure as code makes the environment a versioned, reviewed, repeatable artifact. The same inputs always produce the same infrastructure, and every change has an author and a diff.

We provision with Pulumi, which lets us define cloud resources in real code under source control. To make IaC valuable, treat that code exactly like application code: reviewed, tested, deployed through the pipeline, and never bypassed by manual portal changes. The payoff is reproducibility (rebuild an environment from scratch), auditability (every change is a reviewed commit), and consistency (dev, test, and prod differ only by parameters).

IaC is also a security surface. The code can set secure defaults: private networking, managed identity, the correct region, and least-privilege roles. This makes the whole estate secure by construction. But IaC state and definitions can also leak secrets or grant too much privilege if written carelessly. So the same rules about secrets and least privilege apply here as everywhere.

Define everything as reviewed code

Manage state and secrets safely

Public default, hard-coded secret new azure.sql.Database("db", { /* defaults: public access on */ });
const conn = "Server=...;Password=P@ss!"; // in the IaC source

A database left reachable from the public internet by default, and a secret committed to the repo. The infrastructure itself is now the vulnerability, and it is reproduced on every deploy.

Private, identity-based, region-pinned new azure.sql.Server("sql", { location: "westeurope",
azureadAdministrator: { /* managed identity */ }, publicNetworkAccess: "Disabled" });
// secret read from Key Vault at runtime, not embedded

The region meets residency rules, public access is off, access is identity-based, and no secret lives in the code. It is secure by construction and reproducible.

Self-review checklist

Why it matters: Hand-built infrastructure is a common source of outages you cannot reproduce, configuration drift, and quiet misconfigurations that become breaches. IaC turns the environment into reviewed, versioned, secure-by-default code we can rebuild and audit. It also lets us prove to a regulator exactly how production is configured and who changed it.