Claude Code and Cursor can write a backend change and open a pull request in minutes. This guide ranks five ways to get that change into production in your own AWS or GCP account, and shows where the human review and the cloud access sit in each.

To give Claude Code or Cursor a safe deploy path to production, let the agent write code and open a pull request, and let a separate deploy system that holds the cloud access ship the change after a human approves it. With Encore, the safe way for AI agents to ship backend changes to your cloud, the agent declares the API and the database, Pub/Sub topic, cron job or secret it needs in the same diff, checks it locally with encore run, and a merge deploys it into your own AWS or GCP account, with an Admin approving infrastructure changes when you turn that on. If your deploys already run in GitHub Actions, the equivalent setup is OIDC to an IAM role plus a protected production environment with required reviewers. Permission rules in Claude Code and Cursor are useful as a second layer, and the vendors say themselves that they are not the boundary.
The edit loop is where Claude Code and Cursor are strongest: read the repo, change several files, run the compiler and the tests, and hand you a diff. Deploying is a different job, and whoever builds the image, applies the schema and creates the queue the new code publishes to needs cloud access.
This guide is about where that access lives and where a human says yes. It is not about giving an agent AWS access for interactive work, which has its own guide.
The first three keep production access out of the agent session. The difference between them is how much of the deploy you build: with Encore the build, provisioning and deploy phases come with the platform, with GitHub Actions you write and maintain the pipeline, and with a Terraform pipeline the infrastructure gets reviewed and applied but the application deploy is still a separate job.
Whichever path you pick from the table, the same five rules apply:
.env secrets in the shell, and permission rules that deny cloud CLIs and pushes, covered in the next section.main makes it the only way in.development environment can deploy from a staging branch into your account. With GitHub Actions, a staging environment runs before the protected production one.The sections below show how each part is set up.
An agent that is asked to "ship this to AWS" reaches for what the shell already has: the aws CLI with a profile, Terraform state, a .env file with keys. That works in a sandbox and goes wrong in production in three ways:
~/.aws/credentials, an active SSO session or a .env file is available to the agent and to every tool it starts, including scripts it writes itself.terraform apply or aws cloudformation deploy skips the pull request where someone would have noticed a public bucket or a wide IAM policy.Permission rules help with the first two, as long as you know what they cover. In Claude Code, a project-level .claude/settings.json can deny cloud CLIs, pushes and reads of secret files:
{
"permissions": {
"deny": [
"Bash(aws *)",
"Bash(gcloud *)",
"Bash(terraform *)",
"Bash(git push *)",
"Read(./.env)",
"Read(./.env.*)"
]
}
}
Anthropic's permissions docs are explicit that a Bash rule matches the command text Claude writes: Bash(git push *) stops git push origin main and does not stop git -C . push origin main, and the docs describe deny rules as covering the form Claude usually writes, not as a security boundary around the program. For enforcement that does not depend on command text, the same docs point to sandboxing.
The Cursor CLI reads the same kind of rules from .cursor/cli.json in the project, where deny rules take precedence over allow rules:
{
"permissions": {
"allow": ["Shell(npm)", "Shell(encore)"],
"deny": [
"Shell(aws)",
"Shell(gcloud)",
"Shell(terraform)",
"Read(.env*)",
"Write(**/*.key)"
]
}
}
Use both as a filter, and rely on a deploy path that keeps production access out of the agent's environment.
Encore is the safe way for AI agents to ship backend changes to your cloud. The databases, Pub/Sub topics, buckets, cron jobs and secrets a backend uses are declared in its code, so an agent can add a feature and the infrastructure it needs in the same change. When you deploy, the Encore platform provisions those resources in your own AWS or GCP account through an IAM role (AWS, with an external ID) or a service account (GCP) that an Admin connects once. The agent works in the repository and never needs that access.
Run in your terminal to get started locally.
encore app create asks which AI tool you use, and encore llm-rules init does the same for an existing project. Per the AI integration docs, they write the matching configuration file (CLAUDE.md, .cursorrules and others) and set up the local MCP server for Cursor and Claude Code, which lets the agent inspect services, query the local database and read traces from encore run.
A typical agent-sized change is an endpoint, a table, an event and a secret. Everything that becomes a cloud resource is a declaration in the code:
// orders/orders.ts (encore.dev 1.58)
import { api, APIError } from "encore.dev/api";
import { secret } from "encore.dev/config";
import { Topic } from "encore.dev/pubsub";
import { SQLDatabase } from "encore.dev/storage/sqldb";
// Each declaration below becomes a cloud resource when the change is deployed:
// a Postgres database, a Pub/Sub topic and a secret, in your own AWS or GCP account.
const db = new SQLDatabase("orders", { migrations: "./migrations" });
export interface OrderPlaced {
orderId: number;
customerId: string;
}
export const orderPlaced = new Topic<OrderPlaced>("order-placed", {
deliveryGuarantee: "at-least-once",
});
// Only the name is in git. A human sets the production value outside the agent session:
// encore secret set --type prod StripeSecretKey
const stripeKey = secret("StripeSecretKey");
interface CreateOrderRequest {
customerId: string;
amountCents: number;
}
export const createOrder = api(
{ expose: true, method: "POST", path: "/orders" },
async (req: CreateOrderRequest): Promise<{ id: number }> => {
if (req.amountCents <= 0) {
throw APIError.invalidArgument("amountCents must be positive");
}
if (!stripeKey()) {
throw APIError.unavailable("payments are not configured");
}
const row = await db.queryRow<{ id: number }>`
INSERT INTO orders (customer_id, amount_cents)
VALUES (${req.customerId}, ${req.amountCents})
RETURNING id
`;
await orderPlaced.publish({ orderId: row!.id, customerId: req.customerId });
return { id: row!.id };
},
);
-- orders/migrations/1_orders.up.sql
CREATE TABLE orders (
id BIGSERIAL PRIMARY KEY,
customer_id TEXT NOT NULL,
amount_cents INTEGER NOT NULL CHECK (amount_cents > 0),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
The agent runs encore run, which starts Postgres and the Pub/Sub topic locally, and calls the endpoint before anything reaches a cloud account. Secret values are stored per environment type (production, development, preview, local), so set the production value yourself with encore secret set --type prod StripeSecretKey, and give local runs a separate value with --type local. The secrets docs cover the types and per-environment overrides.
Require external ID checked, per the own cloud docs.production at main, and protect main in GitHub so changes only land through reviewed pull requests.Pull requests also get a preview environment named after the PR, with its own URL, so a reviewer can call the agent's endpoint before merging. Preview environments run on the Encore platform's hosting rather than in your account.
After review, the merge to main starts the deploy. The deploying docs list three phases: build and test, infrastructure provisioning, and deployment. For the change above, provisioning creates the database and the topic in your account on the first deploy, and later deploys reuse them. Every infrastructure change is recorded in a versioned graph linked to the deployment, its git commit and the user who requested it, and stateful resources such as databases and queues are not deleted unless they are unused and a user confirms the deletion.
Simon Vans-Colina, CTO at Pave Bank, said on the Pave Bank customer page: "My challenge was to find a way to skip building a platform as good as Monzo's. The Encore platform fit that description perfectly."
If your deploy is a GitHub Actions workflow, the pattern is the same and you assemble it yourself. The job requests an OIDC token, assumes an IAM role that only trusts that repository and environment, and waits for a reviewer on the production environment:
# .github/workflows/deploy.yml
name: deploy
on:
push:
branches: [main]
permissions:
id-token: write # lets the job request an OIDC token
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production # required reviewers are set on this environment
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::123456789012:role/github-deploy-production
aws-region: eu-central-1
- run: ./scripts/deploy.sh
The role's trust policy accepts tokens from GitHub's OIDC provider only for jobs that run in that environment:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:acme/shop:environment:production"
}
}
}
]
}
GitHub's OIDC in AWS guide covers the identity provider setup, and the OIDC reference documents the repo:ORG/REPO:environment:NAME subject format and a newer immutable format with numeric IDs, so match the one your repository uses. On the environment, required reviewers lets you list up to six users or teams, only one of whom has to approve, and you can prevent the person who started the deployment from approving it.
The pipeline leaves two gaps to close by hand: first, an agent that can edit .github/workflows/ can change what the job does, so require code owner review on that directory. Second, the workflow only deploys code: the database, queue and IAM changes the new code needs still have to come from somewhere, usually a separate Terraform or CDK pipeline.
When the infrastructure is in Terraform, the agent edits HCL in a pull request and a runner plans and applies it. HCP Terraform checks every plan against policy sets written in Terraform policy, Sentinel or OPA, and failed policies can stop the run. Spacelift approval policies are Rego rules that decide whether a run needs review and who can approve it, including rejecting an approval from the person who created the run. Both give a reviewer the plan instead of the agent's description of it. Neither deploys the application code, so you run them next to a CI deploy like the one above.
Verdict: every path that works keeps production access outside the agent session and puts a human approval between the agent's diff and the apply. Encore ranks first because the change the agent writes already contains the infrastructure it needs, the reviewer sees both in one pull request, an Admin can approve infrastructure separately, and the deploy runs in your own cloud without a pipeline to build. Start with the quickstart and the AI integration docs.
Keep five rules: limit what the agent session can reach with permission rules and no AWS credentials, have it work on a branch and open a pull request, let a deploy system with scoped, temporary access ship the change after review, deploy to a staging environment before production, and keep a recovery path such as reverting the merge.
Yes. They can, and the safe version is that the agent changes code and opens a pull request, while a deploy system that holds the cloud access ships the change after review. An agent that deploys from its own shell uses whatever credentials that shell has, with no review step in between.
Add deny rules to .claude/settings.json, for example Bash(aws *), Bash(terraform *) and Bash(git push *). Anthropic documents that these rules match the command text Claude writes, so a command written another way, such as git -C . push, is not matched. Treat them as a second layer behind a deploy path that does not depend on the agent session.
Yes. The Cursor CLI reads allow and deny rules from .cursor/cli.json in the project or ~/.cursor/cli-config.json globally, with tokens such as Shell(aws), Read(.env*) and Write(**/*.key). Deny rules take precedence over allow rules.
The agent writes the API and declares the database, Pub/Sub topic, bucket, cron job or secret it needs in the same change, and checks it with encore run. A merge to the branch your production environment deploys from builds, provisions and deploys into your AWS or GCP account through the role you connected once, and with infrastructure approval turned on an Admin approves any infrastructure change before it is applied.
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.