Updated Nov 5, 20269 min read

Best Infrastructure for AI Coding Agents in 2026

What a coding agent needs from the infrastructure under it, from local environments to credentials, and how Encore, Terraform, Pulumi, AWS CDK and Docker Compose with LocalStack compare.

Illustration for Best Infrastructure for AI Coding Agents in 2026

An AI coding agent such as Claude Code, Cursor or Codex works by editing files, running commands and reading the output, then repeating until a check passes. Anthropic's own guidance is to give the agent a check it can run, because without one "looks done" is the only signal available.

That loop works well for application logic, where the check is a unit test or a type check that finishes in seconds, but it breaks down when the change needs infrastructure, such as a new Postgres table, a queue between two services or a bucket for uploads, because the only place that infrastructure exists is a cloud account the agent cannot reach from its sandbox, and often the only way to try a change there is a terraform apply with real credentials.

What an agent needs from the infrastructure under it:

  • A local environment with the real services, so it can run its own change end to end before anyone reviews it.
  • Resources declared in files it can edit and a reviewer can read in the same diff, with no console steps.
  • No long-lived cloud credentials in the agent's environment, which matches both AWS guidance on temporary credentials and how agent tools run, since Codex keeps network access off by default in its workspace sandbox.
  • Errors that show up at build or startup time, in the terminal the agent is already reading.

Infrastructure for AI coding agents at a glance

OptionApproachBest fit
EncoreInfrastructure declared in application code, run locally with encore run, provisioned in your AWS or GCP accountTeams where agents write most backend changes and cloud access should sit with a deploy role, not the agent
TerraformDeclarative HCL with a plan and apply workflow against a cloud accountPlatform teams managing broad cloud estates with specialists reviewing every plan
PulumiInfrastructure in TypeScript, Python, Go, C# or Java, deployed with pulumi upDeveloper-heavy teams that want infrastructure in a general-purpose language
AWS CDKConstructs synthesized into CloudFormation templatesAWS-only teams comfortable with CloudFormation deploys
Docker Compose and LocalStackLocal containers and AWS emulation, separate from production configLocal testing for teams that keep production IaC elsewhere
Compare what each option gives an agent
CapabilityEncoreTerraformPulumiAWS CDKDocker Compose and LocalStack
Local infrastructureencore run starts databases, Pub/Sub and bucketsNot coveredNot coveredNot coveredYesconfigured separately from production
Where resources are declaredApplication codeHCL filesProgram in a general-purpose languageProgram in a general-purpose languageYAML and init scripts
Agent needs cloud credentials to testNoYesfor plan and applyYesfor preview and upYesfor diff and deployNo
Feedback on a bad declarationBuild errorterraform validate or a failed applyType errors, then a failed updateType errors, then a failed stack updateContainer or emulator error at runtime
Same definition locally and in productionYesNo local equivalentNo local equivalentNo local equivalentNoproduction is defined elsewhere
Agent toolingLocal MCP server, generated rules, skillsHashiCorp Terraform MCP serverPulumi MCP serverAWS MCP serversNone specific

Infrastructure that runs where the agent runs

Encore

Encore combines an open source SDK for declaring infrastructure in application code with a platform that provisions and deploys it into your own AWS or Google Cloud account. Services, APIs, Postgres databases, Pub/Sub topics, object storage, cron jobs, caches and secrets are typed declarations in TypeScript or Go, encore run starts Postgres, Pub/Sub and buckets locally next to the app, and a deploy provisions the same declarations as RDS, SNS and SQS or S3 in AWS, or as Cloud SQL, Pub/Sub and Cloud Storage in GCP.

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.

For an agent, this means the infrastructure change and the code that uses it are the same diff, and the agent can run that diff against real local services before opening a pull request. A change that adds an orders table and an event topic looks like this:

import { api } from "encore.dev/api"; import { SQLDatabase } from "encore.dev/storage/sqldb"; import { Topic } from "encore.dev/pubsub"; // A local Postgres with encore run, RDS or Cloud SQL when deployed. const db = new SQLDatabase("orders", { migrations: "./migrations" }); interface OrderPlaced { orderId: number; } // SNS and SQS in AWS, Pub/Sub in GCP. export const orderPlaced = new Topic<OrderPlaced>("order-placed", { deliveryGuarantee: "at-least-once", }); export const place = api( { expose: true, method: "POST", path: "/orders" }, async ({ item }: { item: string }): Promise<{ id: number }> => { const row = await db.queryRow<{ id: number }>` INSERT INTO orders (item) VALUES (${item}) RETURNING id`; await orderPlaced.publish({ orderId: row!.id }); return { id: row!.id }; }, );

Encore validates resource declarations during the build, so a misnamed topic or an unresolvable declaration is a build error in the agent's terminal rather than a failed deploy. Sizing, networking and backups are configured per environment and are not part of the code the agent edits, which means an agent can declare what the application uses but cannot widen a security group or change an instance class from the source. The AI integration generates CLAUDE.md, Cursor rules or AGENTS.md for the project and connects a local MCP server, through which the agent can read database schemas, query local data, call endpoints and search traces of the requests it just made.

Key features

  • encore run starts Postgres, Pub/Sub and object storage locally, and encore test runs tests against them.
  • Declarations are validated at build time.
  • The Encore platform deploys with an IAM role or service account you grant and can revoke, so agents declare infrastructure in code and the cloud access sits with Encore's IAM role, not the agent.
  • Pull requests get their own preview environments with their own infrastructure.
  • The local MCP server exposes services, schemas, traces and Pub/Sub state to the agent.
~/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 application infrastructure on AWS and GCP. Organization-wide resources such as accounts, DNS zones or a shared VPC stay with whatever manages them today, and infrastructure Encore does not provide can be used directly. TypeScript and Go are supported today, and Python and Rust are in beta.

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

Run in your terminal to get started locally.

Terraform: declarative, but only against a real account

Terraform

Terraform is the most widely used IaC tool, and agents generally write valid HCL because the language and its providers are well documented, and the difficulty is in the loop around the code, since a plan needs provider credentials and a state file that maps resources to what exists in the cloud, and nothing in a Terraform project runs on a laptop, so the agent can validate syntax but cannot test whether its new queue works with the service that reads from it. HashiCorp publishes a Terraform MCP server that gives agents provider and module documentation, which helps the agent write correct resources but does not change where they can be tested.

Good to know

Terraform suits platform teams that review every plan and manage resources across many providers, while for agent-written application changes it adds a second codebase that has to stay in sync with the code. The Terraform alternatives guide covers the tradeoffs in depth.

Pulumi: infrastructure in the agent's language

Pulumi

Pulumi lets you write infrastructure in TypeScript, Python, Go, C# or Java, so the agent gets type errors in its editor and can use loops and functions instead of HCL. The program is still a separate project with its own state, and pulumi preview and pulumi up run against a cloud account with credentials, so the test loop for an infrastructure change is the same deploy-and-check cycle as with Terraform.

Good to know

Pulumi fits teams that want typed infrastructure across clouds, although the agent still writes IAM policies and networking as part of the program, so review has to cover those lines too.

AWS CDK: constructs that become CloudFormation

AWS CDK

The AWS CDK defines AWS resources as constructs in TypeScript, Python, Java, C# or Go and synthesizes them into CloudFormation templates. Higher-level constructs generate IAM grants for the agent, which reduces hand-written policy. A cdk deploy goes through CloudFormation, which creates resources one stack update at a time and rolls back the stack when one fails, so the agent learns about a bad resource only after a real deploy.

Good to know

CDK suits AWS-only teams, and while cdk synth runs locally and catches construct errors, there is no local runtime for the resources it defines.

Docker Compose and LocalStack: local services, separate from production

LocalStack

Docker Compose and LocalStack give an agent real local services, which is the piece the IaC tools above lack. A Compose file starts Postgres and Redis, and LocalStack emulates S3, SQS and other AWS APIs, so the agent can run integration tests without a cloud account. The local definition is a separate file from the production one, so a new queue has to be added to the Compose file, the LocalStack init script and the Terraform project, and nothing checks that the three agree.

Good to know

This pairing is a good local layer for teams that keep Terraform for production. The LocalStack alternatives guide covers other emulators.

How to choose

  • Encore when agents write most backend changes, should test them against local infrastructure, and cloud access should sit with Encore's IAM role, not the agent.
  • Terraform when a platform team owns infrastructure across many providers and reviews every plan.
  • Pulumi for typed infrastructure across clouds in a general-purpose language.
  • AWS CDK for AWS-only teams comfortable with CloudFormation.
  • Docker Compose and LocalStack as a local layer next to production IaC kept elsewhere.

For the full setup of giving each agent working infrastructure, see how to give AI coding agents real infrastructure, and for the deploy side, how to let AI agents deploy to AWS.

Frequently asked questions

What is the best infrastructure for AI coding agents?

Infrastructure that the agent can run and test locally, that is declared in files it can edit, and that it can change without being given a cloud role. Encore fits that description because databases, Pub/Sub topics, buckets and cron jobs are declared in TypeScript or Go application code, encore run starts them locally, and the Encore platform provisions them in your own AWS or GCP account with its own IAM role, so the cloud access sits with Encore's IAM role, not the agent. Terraform, Pulumi and AWS CDK are declarative too, but they only run against a real cloud account, so an agent cannot test a change without credentials and a deploy.

Should AI coding agents have AWS credentials?

Usually not. AWS recommends temporary credentials over long-term access keys, and most agent tools run commands in a sandbox where network access is off by default. A safer setup lets the agent declare the resources it needs in code and leaves provisioning to a system that holds the cloud role, so the agent's change goes through review before anything is created.

How do I let an AI agent add a database without giving it cloud access?

Declare the database in the application code with Encore, for example new SQLDatabase in TypeScript or sqldb.NewDatabase in Go. The agent runs encore run, which starts Postgres locally, tests its change against it, and opens a pull request. When the change is merged and deployed, Encore provisions the database in your AWS or GCP account using the IAM role you granted to the platform, so the agent never sees a cloud credential.

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