Back to blog

Infrastructure as Code and Vibe Coding

You've vibe coded an app. It runs locally. Maybe you even deployed it manually to Vercel or Railway. But then comes the question: how do we do this reliably?

That's where Infrastructure as Code (IaC) comes in. It's the piece most vibe coding workflows completely skip. If you're coming from Lovable specifically, see our migration guidefirst.

What is vibe coding missing?

Most vibe coding tools stop at the application boundary. Nobody is prompting:

Set up a VPC with private subnets, a NAT gateway, an RDS instance with automated backups, and a Lambda function with proper IAM roles

And even if you did, you'd want that infrastructure definition to be versioned, reviewable, and reproducible. Not a one-shot prompt result.

Why IaC matters for AI-built apps

1. Reproducibility

Without IaC, your production environment is manually configured and impossible to recreate. When something breaks, you're debugging blind.

With IaC, you can spin up an identical environment in minutes:

const vpc = new aws.ec2.Vpc("app-vpc", {
cidrBlock: "10.0.0.0/16",
enableDnsHostnames: true,
});
const db = new aws.rds.Instance("app-db", {
engine: "postgres",
instanceClass: "db.t4g.micro",
allocatedStorage: 20,
vpcSecurityGroupIds: [dbSecurityGroup.id],
backupRetentionPeriod: 7,
});

2. AI can help write it

Once you commit to IaC, AI tools become excellent at writing infrastructure code too. Claude Code and Cursor can generate Pulumi or Terraform configurations, and your CI pipeline validates them before they touch production.

3. Code review for infrastructure

When your infrastructure is code, it goes through the same review process as your application. A teammate can catch that you forgot to enable backups or left a security group wide open.

const lambda = new aws.lambda.Function("api", {
runtime: "nodejs20.x",
handler: "index.handler",
memorySize: 256,
timeout: 30,
vpcConfig: {
subnetIds: privateSubnets.map((s) => s.id),
securityGroupIds: [lambdaSg.id],
},
environment: {
variables: {
DATABASE_URL: db.endpoint,
NODE_ENV: "production",
},
},
});

4. Rollbacks become trivial

Deployed a bad infrastructure change? Roll back the commit, push, and your previous infrastructure is restored. No clicking around hopelessly in the AWS console.

The vibe coding + IaC workflow

Here's how we set this up for our clients:

  1. Vibe code the application: Lovable, Bolt, Cursor, Claude Code, whatever works
  2. Define infrastructure in code: Pulumi (TypeScript) or Terraform (HCL)
  3. CI/CD validates everything: application code AND infrastructure changes
  4. Deploy through the pipeline: never manually
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm test
- run: pnpm build
- run: pulumi up --yes --stack production

Choosing your IaC tool

ToolLanguageBest for
PulumiTypeScript, Python, GoTeams already writing TypeScript. Same language for app and infra (Recommended)
TerraformHCLLarge teams with dedicated DevOps, multi-cloud setups
SSTTypeScriptServerless-first AWS projects
CDKTypeScript, PythonAWS-only shops comfortable with CloudFormation

We typically recommend Pulumi or SST for vibe coding teams because you're already thinking in TypeScript. No new language to learn, and AI tools generate excellent Pulumi code.

Both Pulumi and SST go far beyond just AWS. They have first-class support for modern dev platforms like Vercel, Neon, PlanetScale, Cloudflare, Supabase and more. You can manage your entire stack in one codebase.


Want help setting up IaC for your project? Get in touch. We'll get your infrastructure production-ready.