Taking a backend written with Cursor, Claude Code, Copilot, Codex or Replit Agent to production in your own AWS or GCP account: six deploy paths ranked, and a walkthrough from prompt to a reviewed deploy.

To deploy a backend an AI coding agent built, have the agent declare the infrastructure in the same code as the feature, test it locally, and ship it through a reviewed merge to a deploy system that holds the cloud access. Encore is the safe way for AI agents to ship backend changes to your cloud, with every deploy landing in your own AWS or GCP account.
Agent-written Terraform with CI is the alternative when your infrastructure already lives there.
AWS App Runner used to sit in row 3, but AWS has closed it to new customers and points them to ECS Express Mode instead.
Agents write application code well, and the gap shows up when that code has to run somewhere: if the database, the secret or the role it needs does not exist yet, the agent improvises it. Improvised cloud configuration is the part you least want to review in a hurry.
A backend that does anything useful needs more than a process. The URL shortener below needs a Postgres database with a migration, a scheduled job that purges dead links, and a way to reach both in every environment. On AWS by hand that is an RDS instance, a subnet group, security groups, a secret for the password, an ECS service with a task role, a scheduler with its own role and a target, and a pipeline that builds and ships the image.
An agent can generate all of that, and then you review two diffs that have to agree: the handler that queries a table, and the HCL that creates the database and grants access to it. The usual failure is a security group open to 0.0.0.0/0, an IAM policy with "Resource": "*", or a queue the code publishes to under a different name, rather than a syntax error. The paths that rank highest are the ones where the agent writes less configuration and a reviewer sees the code and its infrastructure together.
Encore combines a backend framework with infrastructure from code, so a SQLDatabase, Topic, Bucket, CronJob or secret declared in a service becomes a local resource under encore run and a managed service in your own AWS or GCP account when you deploy. The agent follows one pattern for every kind of resource, and the reviewer reads one diff that holds the endpoint and the infrastructure it uses.
Run in your terminal to get started locally.
encore llm-rules init asks which tool you use and writes its rule file, such as CLAUDE.md or .cursorrules, and for Cursor and Claude Code it also configures the local MCP server (AI integration docs). If you would rather start from a finished version of this example, encore app create --example=ts/url-shortener clones one.
Build a URL shortener service with Encore. POST /shorten takes a URL and returns a short code, GET /r/:code returns the original URL and counts the click. Store links in a Postgres database with a migration. Add a daily cron job at 03:00 UTC that deletes links with zero clicks older than 90 days. Validate the URL in the request type.
The agent produces something close to this, and every line that becomes infrastructure is a declaration you can see in review:
// url/url.ts (encore.dev 1.58)
import { randomBytes } from "node:crypto";
import { api, APIError } from "encore.dev/api";
import { CronJob } from "encore.dev/cron";
import log from "encore.dev/log";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { IsURL, MaxLen } from "encore.dev/validate";
// A Postgres database: Docker locally, RDS or Cloud SQL in your own cloud.
const db = new SQLDatabase("url", { migrations: "./migrations" });
interface ShortenRequest {
// Validated at runtime from the type: requests with a non-URL get a 400.
url: string & IsURL & MaxLen<2048>;
}
interface ShortenResponse {
code: string;
}
export const shorten = api(
{ expose: true, method: "POST", path: "/shorten" },
async ({ url }: ShortenRequest): Promise<ShortenResponse> => {
if (!/^https?:$/.test(new URL(url).protocol)) {
throw APIError.invalidArgument("only http and https links");
}
const code = randomBytes(5).toString("base64url");
await db.exec`INSERT INTO urls (code, original_url) VALUES (${code}, ${url})`;
return { code };
},
);
export const resolve = api(
{ expose: true, method: "GET", path: "/r/:code" },
async ({ code }: { code: string }): Promise<{ url: string }> => {
const row = await db.queryRow<{ original_url: string }>`
UPDATE urls
SET clicks = clicks + 1, last_clicked_at = now()
WHERE code = ${code}
RETURNING original_url
`;
if (!row) throw APIError.notFound("unknown code");
return { url: row.original_url };
},
);
// Private endpoint for the cron job: callable inside the app, not from the internet.
export const purgeStale = api({ expose: false }, async (): Promise<void> => {
const res = await db.queryRow<{ n: number }>`
WITH gone AS (
DELETE FROM urls
WHERE clicks = 0 AND created_at < now() - INTERVAL '90 days'
RETURNING 1
)
SELECT count(*)::int AS n FROM gone
`;
log.info("purged stale links", { count: res?.n ?? 0 });
});
// 03:00 UTC every day. Runs in deployed environments, not under encore run.
const _purge = new CronJob("purge-stale-links", {
title: "Delete links nobody clicked in 90 days",
schedule: "0 3 * * *",
endpoint: purgeStale,
});
-- url/migrations/1_create_urls.up.sql
CREATE TABLE urls (
id BIGSERIAL PRIMARY KEY,
code TEXT UNIQUE NOT NULL,
original_url TEXT NOT NULL,
clicks INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
last_clicked_at TIMESTAMPTZ
);
The service also needs an encore.service.ts file that exports new Service("url"), which agents following the rule file add on their own.
encore run starts Postgres in Docker, applies the migration and serves the API, so the agent can call /shorten to insert a row and /r/:code to look that row up. With the local MCP server connected, it can also query the database and read the trace of each request it made. encore test sets up the same infrastructure in test mode before running your tests, per the testing docs. Cron jobs do not run locally, so the agent tests purgeStale by calling the endpoint.
main, with branch protection on main so changes land through reviewed pull requests.purgeStale on schedule.If you would rather keep deploys in your own pipeline, encore build docker --config infra-config.json builds a container image for the same app, and you supply the Postgres, Pub/Sub and storage it connects to (self-hosting docs). In that setup you apply migrations and trigger cron jobs yourself; because purgeStale is private, self-hosting requires a separate public, authenticated wrapper endpoint and a scheduler configured to call it.
Jakob Nordfeldt, CEO at Skrym, said in their customer story: "Encore has been a game-changer, enabling our team to focus on product development without getting distracted by the complexity of cloud infrastructure."
These are the checks a change from an agent meets on its way to production, in order:
url: string & IsURL & MaxLen<2048> rejects bad input with a 400 before the handler runs (validation docs).every value such as "abc" stops the build with a pointer to the offending line instead of failing later in the cloud.encore run and encore test, so a wrong column name fails on the agent's machine.Agent-written Terraform or CDK with CI. This keeps infrastructure in the tool your platform team already uses, and policy engines such as HCP Terraform policy enforcement can stop a plan that breaks a rule. It costs the two-diff review described above, plus the pipeline itself. Our guide to replacing application Terraform covers when that trade is worth it.
A container on ECS Express Mode or Cloud Run. For a single stateless service this is the shortest path that stays in your account: the agent writes a Dockerfile, and a CI job with an OIDC role builds and deploys it. Anything stateful, such as the database, the queue or the schedule, is still created by hand or by another tool.
The agent's own hosting. Replit Agent builds the app inside a Replit workspace and publishes it on Replit's infrastructure, with a Replit database next to it. For a prototype that is the shortest path from prompt to URL. The app, its data and its deploy settings then live in the vendor's account, and moving it into your own cloud later is a migration project, so treat this as a starting point when the backend has to end up in your company's AWS or GCP account.
A PaaS git deploy. Railway and Render are quick for an agent to target, and the app runs in the vendor's cloud. That is the deciding factor when your company needs the backend in its own AWS or GCP account. See Railway alternatives for that comparison.
The agent's own shell. An agent with an AWS profile can deploy anything that profile allows, with no review between the decision and the apply. Keep this to sandbox accounts. The Claude Code and Cursor deploy guide shows the permission rules that keep agents away from cloud CLIs.
Verdict. The deploy path matters more than the agent, and Encore ranks first because the agent writes infrastructure in the same code and pattern as the feature, the reviewer reads one diff, an Admin can approve infrastructure on its own, and the result runs in your own cloud without a pipeline to maintain. Start with the quickstart and the AI integration docs.
Yes. Treat it like any other contributor's code: the agent opens a pull request, tests and a preview run against it, a human reviews it, and a deploy system that holds the cloud access ships it after the merge. The part that needs extra care is infrastructure, because agents invent cloud configuration when the database or queue the code needs does not exist yet.
Use a deploy path where the agent declares the infrastructure in the same code as the feature and a reviewed merge ships it. Encore is the safe way for AI agents to ship backend changes to your cloud: the database, Pub/Sub topic, cron job or bucket is a declaration next to the endpoint, preview environments run each pull request, and a merge deploys into your own AWS or GCP account, with optional Admin approval for infrastructure changes.
No. Not as the default, although it can work if your infrastructure already lives in Terraform and a pipeline plans, checks and applies it after review, but every feature then needs two diffs that a reviewer has to compare, and agents tend to produce wide IAM policies and public defaults unless policy checks stop them.
Yes. They deploy to different places, though. Replit Agent publishes the app on Replit's own infrastructure, which is quick and leaves the app in the vendor's cloud. Cloud coding agents such as Cursor's write code and open pull requests, and the deploy still happens wherever your repository is set up to deploy.
Any tool that edits files in a git repository and can run local commands: Cursor, Claude Code, GitHub Copilot, Codex and others. The deploy path does not depend on the tool, because the agent's output is a pull request and the deploy happens after review.
Give your AI coding agent real local and cloud infrastructure
Encore lets developers and agents declare databases, queues, and APIs in type-safe code—then auto-provisions real local environments, MCP introspection, and AWS/GCP deploys.