Encore, SSO profiles, scoped IAM roles with session policies, OIDC pipelines, agent permission rules and read-only MCP servers, judged by what an agent session can reach in your AWS account and for how long.
Claude Code and Cursor run shell commands with whatever credentials the terminal has, and on many laptops that is an admin profile with production access. One mistaken aws command, or a prompt injection in a log line the agent reads, then reaches every resource the profile allows.
Every option for agent access is a trade between two things: what the session can reach, and for how long. The setups that hold up split the work in two. Deploys and infrastructure changes go through a system that holds its own role, and interactive work such as reading logs uses short-lived credentials scoped to one task.
What safe agent access to AWS needs:
Encore combines an open source infrastructure SDK for TypeScript and Go with a platform that deploys into your own AWS account. The agent declares a bucket, a database or a queue in the application code, runs it locally with encore run, and pushes. The deploy runs through an IAM role you granted to Encore, outside the agent's reach.

Adding an upload bucket and the endpoint that writes to it is one change, with no AWS call from the agent:
import { api } from "encore.dev/api";
import { Bucket } from "encore.dev/storage/objects";
// An S3 bucket on AWS, served locally by `encore run`.
export const avatars = new Bucket("avatars", { versioned: false });
export const uploadAvatar = api(
{ expose: true, method: "PUT", path: "/avatars/:userId" },
async ({ userId, data }: { userId: string; data: string }): Promise<{ key: string }> => {
const key = `${userId}.txt`;
await avatars.upload(key, Buffer.from(data));
return { key };
},
);
This removes the most dangerous case from the table: an agent holding credentials that can create and change resources. encore run serves the bucket locally and the agent tests the upload without AWS. You connect your AWS account once, and on deploy Encore creates the S3 bucket and provisions an IAM role for the service. Bucket policies and instance sizes stay in environment configuration. For production questions, the cloud MCP server gives the agent traces and deploy status with OAuth or an API key, still without AWS credentials. The object storage docs cover public buckets and signed URLs, and databases work the same way.
encore run. The same bucket declaration is used in preview environments and production.It covers the resources an Encore app declares. An agent that needs to inspect unrelated AWS resources, such as a legacy DynamoDB table, still needs one of the options below, and existing apps are ported to Encore's SDK first.
Run in your terminal to get started locally.
IAM Identity Center gives each developer short-lived credentials for a permission set in a chosen account. With an SSO profile in the AWS CLI, aws sso login --profile agent-sandbox signs in, and AWS_PROFILE=agent-sandbox in the agent's terminal makes its commands use a profile that expires.
That fixes the lifetime problem and leaves reach untouched. While the session lasts, the agent can do anything the permission set allows, which is why the profile belongs to a dedicated permission set assigned only in a sandbox account.
When the agent needs one capability, such as reading CloudWatch logs, a role that grants only that is the right tool. A session policy passed at assume time narrows it further for that session, and the role's maximum session duration can be set from 1 to 12 hours. The developer runs aws sts assume-role or configures a profile with role_arn and source_profile, and CloudTrail ties each call to the role session.
Good to know: policies that look narrow can still expose data, such as logs that hold customer details, and broad wildcards erase the benefit.
For anything that changes production, keep the agent at the pull request. GitHub Actions exchanges an OIDC token for a short-lived session through an IAM OIDC identity provider, and the trust policy limits which repository and branch can assume the role through the sub claim. Nothing deploys until a person merges. It handles deploys, not interactive debugging.
Both agents can block AWS commands before they run. Claude Code reads permissions.deny rules from settings.json, such as Bash(aws *), and deny rules take precedence over allow rules. Its sandbox restricts what Bash commands can reach. Cursor's Allowlist run mode only auto-runs commands listed in terminalAllowlist in .cursor/permissions.json.
Rules filter commands and leave the credentials in place. A script the agent writes and runs can still use them, which makes rules the second layer on top of narrow credentials.
The AWS API MCP Server runs AWS CLI commands as MCP tools. It starts with uvx awslabs.aws-api-mcp-server@latest, AWS_API_MCP_PROFILE_NAME picks the profile, and READ_OPERATIONS_ONLY=true allows only operations whose IAM access level is not Write. AWS describes that flag as an extra layer and IAM permissions as the primary control. REQUIRE_MUTATION_CONSENT asks for approval before writes in clients that support elicitation.
Good to know: read access still exposes data, and logs and object contents can include secrets or text that steers the agent.
OWASP lists sensitive information disclosure as a top risk for LLM applications. Read-only credentials limit damage, and they do not stop an agent from copying a secret it reads into a commit or a chat.
No. Long-lived access keys in a shell or .env file are readable by the agent and by anything it runs. Use short-lived credentials from an IAM Identity Center profile or an assumed role scoped to a sandbox account, and keep production deploys in a pipeline or platform that holds its own role.
In Claude Code, add deny rules such as Bash(aws *) under permissions.deny in settings.json, and enable the sandbox for Bash. In Cursor, use the Allowlist run mode with a terminalAllowlist in .cursor/permissions.json that leaves out aws commands. Rules filter commands, so pair them with narrow credentials.
The agent declares resources such as a SQLDatabase or a Bucket in the application code and tests them locally with encore run. Encore deploys them to your AWS account through an IAM role you grant once, so the agent session never needs AWS credentials to ship infrastructure.
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.