- One giant state file is the most common IaC mistake: split by environment and blast radius before you hit 200 resources.
- Drift is normal. Ignoring it is the mistake. Run a scheduled plan and alert on non-empty diffs.
- Secrets in tfvars, state, or plaintext CloudFormation parameters leak through CI logs and S3 buckets more often than through code review.
- For a pre-product-market-fit startup, a hand-built console setup plus a snapshot beats a 40-module Terraform repo you can't maintain.
- The right IaC scope is the resources you rebuild more than once a month, not every resource your cloud account can create.
You know the feeling: it's 2 a.m. your staging environment is down, and the only person who understands the Terraform state file is on vacation. You try to apply a fix, but the plan shows 47 changes you didn't make, including a database replacement. That's not a tooling problem. It's a state and scope problem, and it's the kind of thing that quietly kills velocity at startups. Devs & Logics builds SaaS MVPs, web platforms, and cloud infrastructure for US startups and enterprises, and we've seen the same infrastructure as code mistakes repeat across teams of every size. For a broader foundation, our guide to DevOps best practices for startups covers the principles; this piece focuses on where IaC specifically goes wrong.
Why Do Infrastructure as Code Projects Fail at Startups?
Most IaC failures at startups come from copying enterprise repo structures into a product that ships weekly, not from picking the wrong tool. The tooling is rarely the problem; the scope and state model are.
Enterprise Terraform repos are designed for teams of 50 with dedicated platform engineers. They have modules for every VPC, every IAM role, and every database, plus Terragrunt to manage the layers. A five-person startup copies that structure because it looks professional, then spends more time maintaining the modules than shipping features. The repo becomes a second product nobody asked for.
The failure pattern is predictable. First, someone adds a module for a resource you use once. Then a second environment gets bolted onto the same state file because splitting feels like overhead. Then a contractor runs terraform apply from a laptop without locking, and the state file in S3 gets corrupted. By the time you notice, you're afraid to run plan because you don't know what it will try to destroy.
The fix starts with scope: decide which resources actually need code. If you rebuild your VPC once a year, a documented console setup is fine. If you spin up a new preview environment per pull request, that has to be automated. The line is frequency, not ideology.
The Monolithic State File Anti-Pattern (and How to Split It)
A single Terraform state file holding every environment, every VPC, and every database is the most common infrastructure as code mistake because it turns every change into a full-blast-radius operation. Split state by environment and by lifecycle before you cross roughly 100 to 200 resources.
State is Terraform's source of truth. When everything lives in one file, a plan for a staging change has to lock the same state that production uses. A corrupted state file takes down every environment at once. A botched apply can replace a production database because a staging resource changed. And plan times balloon: we've seen 15-minute plans on monolithic repos, which kills the feedback loop that makes IaC worth using.
The split we recommend for most startups:
- By environment: separate state for dev, staging, and production. Use separate AWS accounts if you can, or at minimum separate S3 buckets and DynamoDB lock tables.
- By lifecycle: network layer (VPC, subnets, security groups) changes rarely; application layer (ECS services, Lambda functions, RDS) changes weekly; data layer (S3 buckets, backups) changes almost never. Put each in its own state.
- By blast radius: anything that could delete data or take down production gets its own state with stricter review and manual approval.
Use a remote backend with locking from day one. For AWS, that means an S3 bucket with versioning enabled and a DynamoDB table for state locking. Here's the minimal backend config:
terraform { backend "s3" { bucket = "mycompany-terraform-state" key = "prod/network/terraform.tfstate" region = "us-east-1" dynamodb_table = "terraform-locks" encrypt = true }
}The key includes the environment and layer, so each stack gets its own state file. Enable bucket versioning so you can roll back a corrupted state. Never commit state to git, and never let two engineers apply without locking.
Drift Management: Why Your Plan Keeps Showing Changes You Didn't Make
Drift is the gap between what your code says and what your cloud account actually contains, and it appears the moment anyone touches the console. The fix isn't banning console access; it's detecting drift on a schedule and reconciling it deliberately.
Someone adds a security group rule in the AWS console to debug an issue and forgets to remove it. A autoscaling event changes the desired count. A manual RDS parameter tweak never makes it back to code. None of these are malicious, but each one means your next apply might revert a fix or, worse, conflict with it.
The practical approach: run terraform plan on a schedule (nightly or every few hours) in CI and alert when the plan is non-empty. Don't auto-apply. The alert should go to the engineer who owns that stack, with a link to the plan output. They decide whether to update the code to match reality or revert the console change.
For teams using GitHub Actions, a scheduled workflow with terraform plan -detailed-exitcode returns exit code 2 when there are changes, which you can use to fail the job and notify. Pair this with a policy that all console changes get a ticket and a follow-up commit within 24 hours. Drift becomes a signal, not a surprise.
This is also where CI gates matter. Just as you'd run unit tests before merging, you run plan before applying. Our software testing and QA services with CI gates apply the same discipline to application code, and the principle carries over: automate the check, make the failure visible, and require a human decision before the change lands.
Secret Leakage in Terraform, Pulumi, and CloudFormation
Secrets leak through IaC most often via committed tfvars files, plaintext state, and CI logs that echo plan output, not through clever attacks. Treat state as a secret store and keep credentials out of the repo entirely.
Terraform state contains every attribute of every resource, including database passwords, API keys passed as variables, and connection strings. If that state lives in an unencrypted S3 bucket with broad read access, your secrets are one misconfigured bucket policy away from exposure. Pulumi state has the same property: it stores outputs and inputs, including secrets unless you mark them.
The fixes are straightforward but easy to skip:
- Encrypt state at rest: S3 server-side encryption with KMS, and restrict bucket access to the CI role and a small admin group.
- Never commit tfvars with secrets: use environment variables or a secrets manager. For Terraform, the
sensitive = trueflag hides values in plan output but does not encrypt state. - Use a secrets manager: AWS Secrets Manager, SSM Parameter Store, or HashiCorp Vault. Reference secrets at apply time, not in code.
- Sanitize CI logs: plan output can print sensitive values. Use
-no-colorand review what gets logged. In GitHub Actions, mask secrets with::add-mask::.
For Pulumi, mark secrets with pulumi.Config.requireSecret so they're encrypted in state and redacted in output. For CloudFormation, use NoEcho: true on parameters and dynamic references to Secrets Manager instead of plaintext parameter values.
The honest tradeoff: managing secrets in IaC adds friction. Every rotation requires a code change or a parameter update. Some teams keep database passwords out of IaC entirely and rotate them via a separate process. That's fine as long as the process is documented and the state file doesn't contain the secret.
Terraform vs Pulumi vs CloudFormation: Which Mistakes Bite Hardest
Each tool has a characteristic failure mode: Terraform punishes state mismanagement, Pulumi punishes untested general-purpose code, and CloudFormation punishes slow feedback loops. Pick based on which failure your team can actually catch in review.
Terraform's HCL is declarative and constrained, which makes review easier but state management harder. Pulumi lets you write infrastructure in TypeScript or Python, which is powerful for teams already fluent in those languages but invites the same bugs as application code: loops that create unintended resources, conditionals that behave differently across environments, and tests that don't cover the infrastructure path. CloudFormation is deeply integrated with AWS but has slower iteration and a more verbose template format, which can hide mistakes until deploy time.
| Tool | Characteristic failure mode | Best fit | Watch out for |
|---|---|---|---|
| Terraform | State mismanagement, monolithic state, drift | Multi-cloud or hybrid teams; teams that want a large provider ecosystem | State locking, remote backend, and module sprawl |
| Pulumi | Untested general-purpose code, logic bugs in infrastructure | Teams fluent in TypeScript or Python who want real programming constructs | Unit tests for infrastructure code; secret handling in state |
| CloudFormation | Slow feedback loops, verbose templates, rollback surprises | AWS-only teams that want native integration and no extra tooling | Stack update failures; drift detection requires extra setup |
For most startups in 2026, Terraform remains the default because the provider ecosystem and community modules are mature, and the declarative syntax limits the blast radius of a single engineer's mistake. Pulumi is a strong choice if your team already writes TypeScript daily and you want to share types between application and infrastructure. CloudFormation makes sense if you're all-in on AWS and want to avoid managing state yourself, but be ready to invest in faster feedback through aws cloudformation validate-template and change sets.
Over-Engineering IaC Before Product-Market Fit
If your product hasn't found fit, a 40-module Terraform repo with Terragrunt, Atlantis, and a custom provider is a liability, not an asset. Scope IaC to what you rebuild more than once a month and leave the rest in the console.
We've seen pre seed startups spend three weeks building a Terraform module for a single RDS instance and a VPC. That's three weeks not spent on onboarding, billing, or the core feature. The infrastructure worked, but the product didn't ship. For context on where engineering time should go at that stage, see what a SaaS MVP actually costs in 2026; infrastructure is usually a small line item compared to product work.
The right scope for a pre-fit startup:
- Automate anything you rebuild more than once a month: preview environments, CI runners, staging resets.
- Keep production on a documented console setup with a snapshot and a runbook. If it breaks, you can rebuild in an hour.
- Use managed services (Vercel, Supabase, RDS) to avoid infrastructure you'd have to codify.
- Add IaC when you add a second environment or a second engineer who needs to reproduce your setup.
This is the honest tradeoff: for a pre-product-market-fit startup, a hand-built console setup plus a documented snapshot often beats a custom Terraform repo. If you rebuild infrastructure less than once a month, the maintenance cost of IaC modules exceeds the recovery time from a manual rebuild. Adopt IaC when the rebuild frequency or the number of environments crosses the point where manual drift becomes expensive.
A Practical IaC Reset for Early-Stage Teams
The fastest reset is to inventory what you actually rebuild, move state to a locked remote backend, split by environment, and wire drift detection into CI before adding any new modules. Do this in a week, not a quarter.
Here's the sequence we've used with teams, including on how we shipped an AI-native SaaS MVP with RAG in six weeks:
- Day 1: Inventory. List every resource in your cloud account and mark it as code-managed, console-managed, or unknown. Unknown is the dangerous category; find out what it is before you touch anything.
- Day 2: Backend. Create an S3 bucket with versioning and a DynamoDB lock table. Migrate existing state with
terraform init -migrate-state. If you have no state, import the resources you want to manage. - Day 3: Split. Separate state by environment and lifecycle. Use workspaces or separate directories; either works, but be consistent. Update CI to use the right backend key per stack.
- Day 4: Drift detection. Add a scheduled CI job that runs plan and alerts on non-empty output. Start with production only, then expand.
- Day 5: Secrets audit. Grep the repo for tfvars, check state bucket permissions, and rotate any secret that was ever committed. Move secrets to a manager.
After the reset, add modules only when you have a second use case. A module used once is just indirection. A module used three times pays for itself.
If your team is underwater on infrastructure and needs a reset without pausing product work, our DevOps and cloud engineering services cover CI/CD, AWS, and Vercel setups with the same scope discipline. We also offer the free MVP launch playbook if you're earlier in the process and want a checklist before you touch Terraform.
Frequently Asked Questions
Should a startup use Terraform or Pulumi in 2026?
Terraform is the safer default for most startups because its declarative syntax and mature provider ecosystem reduce the chance of logic bugs in infrastructure code. Pulumi is a strong choice if your team writes TypeScript or Python daily and wants to share types and tests between application and infrastructure. The decision matters less than state management and scope discipline; a well-run Terraform repo beats a poorly run Pulumi repo every time.
How do I fix a Terraform state file that has drifted from reality?
Run terraform plan to see the diff, then decide per resource whether to update the code to match reality or revert the console change. Use terraform import for resources that exist but aren't in state, and terraform state rm for resources that are in state but no longer exist. Never run terraform apply on a drifted state without reviewing the plan line by line, especially for anything that could delete data.
Where should Terraform state live for a small team?
An S3 bucket with versioning, encryption, and a DynamoDB lock table is the standard for AWS-based teams. For teams on GCP, a GCS bucket with object versioning works similarly. The key requirements are remote storage, locking, encryption at rest, and access restricted to CI and a small admin group. Never keep state on a laptop or in git.
Is CloudFormation still worth using for AWS-only startups?
Yes, if you're all-in on AWS and want native integration without managing state yourself. CloudFormation handles state, rollback, and drift detection through change sets, which removes a category of mistakes. The tradeoff is slower feedback and more verbose templates, so invest in validation and change sets before applying. For multi-cloud or hybrid teams, Terraform is usually a better fit.
Key Takeaways
- Split state by environment and blast radius before you hit 200 resources; monolithic state turns every change into a production risk.
- Drift is normal. Detect it on a schedule, alert on non-empty plans, and reconcile deliberately instead of banning console access.
- Scope IaC to what you rebuild more than once a month. For pre-fit startups, a documented console setup often beats a 40-module repo.
If you want a second set of eyes on your infrastructure before your next funding round or launch, talk to our DevOps and cloud team about a reset that ships in a week, not a quarter.
