/Glossary · DevOps
What is Infrastructure as code?
Infrastructure as code (IaC) is the practice of defining servers, networks, permissions and cloud services in version-controlled files instead of configuring them by hand. That way infrastructure is reviewed, tested and deployed just like software.
How infrastructure as code works
You describe the desired state in declarative code, for example a VPC, an ECS cluster and an Aurora database. A tool compares that state with what exists in the account, computes a plan of changes and applies it. Every change goes through a pull request, gets recorded and can be rolled back.
On AWS the main options are Terraform or OpenTofu, AWS CloudFormation and AWS CDK, which generates CloudFormation from TypeScript, Python or other languages. They all solve the same problem with a different approach: Terraform is multi-provider, CloudFormation is native and managed, and CDK gives you the expressiveness of a programming language.
When to use IaC
Practically any time infrastructure will live longer than a few weeks. It matters most if you need several identical environments, if you have to prove controls in an audit, or if you want to rebuild an entire account after a disaster. Without code, every environment drifts and nobody knows exactly what is deployed.
For a one-day proof of concept the console is fine, but as soon as something reaches production it should move to code. You can import existing resources with terraform import or CloudFormation resource import, so there is no need to start from scratch.
Best practices and common mistakes on AWS
Organize code into reusable modules, split state by environment and by domain, and run changes from a pipeline using IAM roles and OIDC. Add automated checks with tools like tflint, Checkov or cfn-guard to catch insecure configurations before they are applied.
The most common mistake is mixing manual console changes with changes made through code, which creates drift and unpredictable plans. Another frequent problem is a single giant state file for the whole company: any minor change blocks everyone else and widens the blast radius of a mistake.
/FAQ
Questions about Infrastructure as code
Another question? Write to hello@nubent.com and an engineer will answer.
Which is better, Terraform or CloudFormation?
It depends on the context. Terraform is a good fit if you manage several providers or already have experience with it. CloudFormation is native to AWS, needs no state management and integrates with StackSets and Control Tower. Both are solid when applied with discipline.
What is drift in infrastructure as code?
It is the gap between what the code defines and what actually exists in the account, usually caused by manual changes. You detect it with terraform plan or CloudFormation drift detection, and you prevent it by restricting write permissions in the console.
Is AWS CDK infrastructure as code?
Yes. AWS CDK lets you define infrastructure in languages like TypeScript or Python and synthesizes it into CloudFormation templates. It works well for development teams that prefer high-level abstractions and want to reuse logic with functions and classes.
How we help with Infrastructure as code
Building on AWS
AWS architecture designed and built from scratch: accounts, networking, access, CI/CD and observability in Terraform, ready to grow without a rebuild.
Learn morePlatform Engineering
An internal developer platform on AWS with golden paths, Backstage and Terraform self-service, for autonomous teams that ship quickly and safely.
Learn moreDevOps as a Service
An ongoing external DevOps team for your AWS infrastructure: Terraform, CI/CD, security, costs and on-call coverage, on a monthly subscription.
Learn moreDevOps with AI agents
DevOps operations assisted by AI agents: Terraform changes by pull request, alert triage, cost reviews, runbooks and postmortems, always with human approval.
Learn moreNext step
What should we build next on AWS?
30 minutes with an engineer. Concrete next steps, whether or not you work with us.