What Infrastructure as Code Actually Means
Infrastructure as Code means writing the definition of your cloud infrastructure in files that can be stored in version control, reviewed in pull requests, and applied automatically through a pipeline. Instead of clicking through the AWS Console to create a database, a load balancer, and a cache cluster, you write a configuration file that describes those resources and their relationships. A tool reads that file and provisions the infrastructure to match. If you need to recreate the infrastructure in a new region, you run the same file. If someone makes a change through the console that deviates from the configuration, IaC tools can detect and flag the drift. The version control aspect is particularly valuable for security and compliance: you have an audit trail of every infrastructure change, who made it, when, and why. This is directly relevant to ISO 27001 change management requirements and SOC 2 audit evidence. For AI products where infrastructure includes GPU instances, vector database clusters, and LLM API gateway configuration, IaC ensures these are provisioned consistently and securely across environments.
Terraform vs Pulumi: Choosing a Tool
Terraform is the most widely used IaC tool globally and the default choice for most UK startups. It uses a declarative configuration language called HCL to describe the desired state of infrastructure. The Terraform ecosystem is mature with providers for AWS, GCP, Azure, Vercel, Cloudflare, and virtually every other cloud service. Terraform state, which tracks what infrastructure exists, can be stored remotely in Terraform Cloud, AWS S3, or similar backends, enabling team collaboration. Pulumi is a newer alternative that lets you write infrastructure configuration in TypeScript, Python, Go, or other programming languages you may already know. For teams building AI products in TypeScript, Pulumi can be attractive because infrastructure and application code share the same language toolchain. The trade-off is a smaller ecosystem and less community documentation than Terraform. For most UK AI startups, Terraform is the pragmatic choice because hiring and external documentation are substantially easier. Start with Terraform unless your team has a strong existing preference for Pulumi or you have complex infrastructure logic that benefits from a general-purpose programming language.
What to Manage with IaC and What Not To
Not everything belongs in IaC from the start of a project. The practical guidance is to use IaC for infrastructure that is expensive to recreate, security-sensitive, or shared across environments. This includes VPC and network configuration, database clusters and their security group rules, container orchestration infrastructure, IAM roles and policies, API gateways, CDN configuration, and DNS records. Application-level configuration and feature flags are better managed through environment variables and purpose-built feature flag tools rather than IaC. Secrets such as API keys should be managed through a secrets manager and referenced by IaC but never stored in IaC configuration files. For very early-stage AI MVPs where the infrastructure is a single Vercel deployment and a managed PostgreSQL database on Neon or Supabase, IaC may be premature. The overhead of setting it up exceeds the benefit when the infrastructure is minimal and fully managed. As infrastructure grows to include multiple services, custom networking, or GPU workloads for AI inference, introducing IaC becomes worthwhile.
IaC in a CI/CD Pipeline
IaC becomes most powerful when integrated into a CI/CD pipeline that automatically applies infrastructure changes on merge to a protected branch. The standard pattern is to run a Terraform plan on every pull request, which shows what infrastructure changes the PR would make without applying them. Reviewers can inspect the plan output alongside the configuration change, making infrastructure reviews concrete rather than abstract. On merge to main, the pipeline runs a Terraform apply to enact the changes. This means infrastructure changes go through the same review and approval process as application code changes. Access to run Terraform apply directly should be restricted or eliminated for individual developers once the pipeline is in place. All infrastructure changes flow through the pipeline, creating a complete and auditable history. For AI products with multiple environments, separate Terraform workspaces or directories for development, staging, and production allow the same configuration to be applied to each environment with environment-specific variable overrides.
Disaster Recovery and IaC
One of the most undervalued benefits of IaC is what happens when something goes catastrophically wrong. If your production database is accidentally deleted, your container registry is corrupted, or a misconfiguration takes down your networking, the ability to recreate your entire infrastructure from configuration files transforms a potential multi-day incident into a matter of hours. The practical requirement is that your IaC configuration is comprehensive enough to recreate a working environment and that it is tested periodically. Many teams have IaC that covers most of their infrastructure but has manual steps that are undocumented. Those gaps will surface at the worst possible moment. A good practice is to periodically provision a complete staging environment from IaC from scratch, verifying that the configuration is complete and the resulting environment actually works. For AI products where infrastructure costs make full environment recreation expensive to test, at minimum document the manual steps that IaC does not cover and test the documentation.
IaC for AI-Specific Infrastructure
AI products have infrastructure requirements that benefit particularly from IaC. GPU instances for model inference are expensive and configuration-sensitive: getting the instance type, region, and network configuration right in code prevents costly mistakes from manual provisioning. Vector database clusters, whether self-hosted Weaviate on Kubernetes or managed Pinecone through a Terraform provider, benefit from having their configuration versioned and reviewable. LLM API gateway configuration, including rate limiting rules, model routing logic, and fallback behaviour, is easier to manage correctly when it is in code rather than configured through a web console. At SpeedMVPs, we include IaC configuration for non-trivial infrastructure in project deliverables, ensuring clients receive documented, reproducible infrastructure alongside their application code. For simpler projects on Vercel with managed database services, we document the equivalent manual setup steps and environment variable requirements in project handover documentation.