Oct 27, 20267 min read

The Best Infrastructure as Code Tools for AI Coding Agents in 2026

Encore, Pulumi, Terraform, OpenTofu, AWS CDK and Crossplane, judged by how many checks an agent gets on its own infrastructure change before anything is applied.

An agent writing infrastructure code has the same problem as one writing application code: it needs to know whether the change works before it moves on. With application code it runs the tests. With most infrastructure as code tools, the only real test is an apply against a cloud account, and a wrong argument can open a bucket or replace a database.

The way to compare these tools for agents is to count the checks the agent gets on its own before an apply. A compiler, a local run and a preview each catch a different class of mistake, and more of them means fewer surprises reaching review.

What an agent needs from an infrastructure as code tool:

  • Errors on a wrong argument at build time, in the terminal the agent is reading.
  • A way to run the resources it declared, not only plan them.
  • A preview or diff a reviewer can read next to the code change.
  • A licence and governance model the team is comfortable building on.

Infrastructure as code tools for agents at a glance

ToolLanguageChecks before applyAgent toolingLicence
EncoreTypeScript or Go application codeBuild-time validation, local run, preview environmentsLocal and cloud MCP serversOpen source SDK (MPL 2.0)
PulumiTypeScript, Python, Go, C#, Java, YAMLType checks, pulumi previewPulumi MCP server, Neo agentApache 2.0
TerraformHCLterraform validate, terraform planTerraform MCP ServerBSL 1.1
OpenTofuHCLtofu validate, tofu planTerraform-style toolingMPL 2.0
AWS CDKTypeScript, Python, Java, C#, GoType checks, cdk synth, cdk diffAWS MCP serversApache 2.0
CrossplaneKubernetes YAML and compositionsSchema validation at the API serverKubernetes toolingApache 2.0
Compare what each tool lets an agent check
CapabilityEncorePulumiTerraformOpenTofuAWS CDKCrossplane
Type errors on wrong argumentsYesYesNoNoYesSchema errors
Runs the resources locallyYes, encore runNoNoNoNoNo
Needs cloud credentials to previewNoYesYesYesYesfor diffA cluster
What the agent describesResources the app usesAny resourceAny resourceAny resourceAWS resourcesClaims on compositions
CloudsAWS and GCPManyManyManyAWSMany

Encore: infrastructure the agent can run, not just plan

Encore

Encore is an open source infrastructure SDK for TypeScript and Go that declares infrastructure in the application code. The agent declares a database, a topic or a bucket where the code uses it, and Encore derives what to provision. encore run starts those resources locally, and a deploy creates them in your own AWS account or GCP project.

Application code passes through Encore and infrastructure guardrails to resources provisioned in your own AWS or GCP account.
Encore provisions the infrastructure your application needs in your own AWS or GCP account.

Adding a database and an endpoint that writes to it is one change:

import { api } from "encore.dev/api"; import { SQLDatabase } from "encore.dev/storage/sqldb"; // RDS on AWS, Cloud SQL on GCP, a local Postgres with `encore run`. const db = new SQLDatabase("notes", { migrations: "./migrations" }); export const addNote = api( { expose: true, method: "POST", path: "/notes" }, async ({ text }: { text: string }): Promise<{ id: number }> => { const row = await db.queryRow<{ id: number }>` INSERT INTO notes (text) VALUES (${text}) RETURNING id`; return { id: row!.id }; }, );

This gives the agent all three checks. A misnamed resource or a wrong option is a build error. encore run starts Postgres and applies the migrations, as the database docs describe, and the agent calls addNote to see the row come back. The pull request then gets a preview environment with its own database. On deploy, Encore provisions the resources in your AWS account or GCP project and provisions an IAM role for the service. Sizes, networking and backups are set per environment, and AI integration covers the agent rules and MCP server.

Key features

  • Postgres, Pub/Sub, cron jobs, object storage and secrets as typed declarations.
  • Build-time validation of every declaration.
  • Local infrastructure with encore run and encore test.
  • Deploys to AWS or GCP from the same code.
  • A local MCP server for schemas, traces and endpoint calls.
~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders
An agent adds receipt storage to an orders service and tests it locally with encore run. The same bucket declaration is used in preview environments and production.

Good to know

Encore covers the resources a backend uses, not every cloud service. A CloudFront distribution or an organization-wide VPC stays in Terraform or Pulumi next to it.

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

Pulumi: type errors before the preview

Pulumi

Pulumi gives the agent the first check for free: a wrong argument in a TypeScript program is a compiler error before anything talks to the cloud. The second check is pulumi preview, which shows the resource diff and needs credentials for the target account. Pulumi also ships an MCP server, locally under Apache 2.0 and as a hosted endpoint, and Neo, its own infrastructure agent with policy checks and approval steps.

What it cannot do is run the resources. The agent still writes the VPCs, roles and security groups, a typed program can describe a public bucket as easily as a private one, and policy packs and the preview do the rest of the safety work. The CLI is open source and state can live in your own backend, with Pulumi Cloud's free edition covering one user without Neo.

Terraform: the most examples, checked only by a plan

Terraform

Terraform has the largest body of public HCL, and the Terraform MCP Server gives agents current provider and module docs and can manage HCP Terraform workspaces. HashiCorp warns not to use the server with untrusted MCP clients or models, since it can expose Terraform data to them.

The agent's checks are terraform validate for syntax and terraform plan against real state and credentials. Mistakes in argument types surface at plan or apply time rather than in the editor. Terraform 1.6 and later use the Business Source License 1.1, and HashiCorp has been part of IBM since February 2025.

OpenTofu: Terraform's loop under an open source licence

OpenTofu

OpenTofu is the MPL 2.0 fork of Terraform, accepted into the CNCF in April 2025, with client-side state encryption that Terraform's open releases lack. For agents, the loop matches Terraform's: validate, then plan against an account.

Good to know: some newer Terraform features differ between the two, and an agent trained on recent Terraform docs can suggest syntax OpenTofu does not support.

AWS CDK: typed stacks, CloudFormation feedback

AWS CDK

The CDK gives the agent types and L3 patterns that collapse a load balanced service into one class, and cdk synth runs locally to catch construct errors. After that, the feedback comes from CloudFormation: cdk diff against the account, then a deploy that rolls back when a resource fails. The synthesized template is much longer than the code the agent wrote, which makes the diff the thing to review.

Crossplane: claims reviewed in Git, reconciled continuously

Crossplane

Crossplane turns a Kubernetes cluster into a control plane for cloud resources, and graduated in the CNCF in late 2025. Platform teams publish compositions, and agents request resources through short claims that the API server validates against a schema. There is no plan step: once a claim is applied, the controllers reconcile it, which puts the whole review at the pull request.

Why the checks matter

Martin Fowler's description of infrastructure as code rests on reviewable, repeatable definitions, and agents raise the volume of changes to review. The Thoughtworks Technology Radar tracks infrastructure as code as a technique, and the same discipline applies to agent diffs. For the licence question, see IBM's completed HashiCorp acquisition and OpenTofu's CNCF project page.

How to choose

  • Encore when agents add databases, queues and buckets for a backend and you want them type-checked, run locally and previewed before they reach your AWS or GCP account.
  • Pulumi for typed infrastructure across many providers, with its own agent.
  • Terraform for the largest provider ecosystem and an existing HCL estate.
  • OpenTofu for the Terraform workflow under an open source licence.
  • AWS CDK for typed, AWS-only stacks with CloudFormation rollback.
  • Crossplane for platform teams on Kubernetes that want agents to request resources through claims.

Frequently asked questions

Which infrastructure as code tool is best for AI coding agents?

The one that gives the agent the most checks before an apply. Encore declares infrastructure in application code, catches bad declarations at build time and runs the resources locally with encore run. Pulumi and the AWS CDK add type checking before a preview. Terraform and OpenTofu rely on validate and plan, which need a real cloud account.

Do AI agents write better Terraform or Pulumi?

Agents have seen more HCL, and the Terraform MCP Server supplies current provider and module docs. Pulumi programs get type errors from the host language before a preview, and Pulumi offers its own MCP server and the Neo agent. Both still need a human to read the plan or preview.

How do I let an agent add a Postgres database with Encore?

The agent creates a SQLDatabase from encore.dev/storage/sqldb with a migrations folder, runs encore run to start Postgres locally and test the change, and opens a pull request. On deploy, Encore provisions RDS on AWS or Cloud SQL on GCP in your account.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders