Updated Nov 23, 20268 min read

How to Access AWS Without Access Keys

Long-term access keys are the credential AWS tells you to avoid. This guide covers what replaces them for developers, code running on AWS, CI pipelines, servers outside AWS and AI coding agents, and how to stop most of the team from needing AWS credentials at all.

Illustration for How to Access AWS Without Access Keys

You cannot call private AWS resources without any credentials, but you can stop creating and storing long-term access keys. People sign in with aws login or IAM Identity Center, code running on AWS gets credentials from an IAM role, CI pipelines use OIDC, and servers outside AWS use IAM Roles Anywhere, so every credential expires on its own. To stop developers and AI coding agents from needing AWS credentials at all, Encore runs the backend locally with local infrastructure and deploys it to your AWS account through a role you connect once.

An access key in ~/.aws/credentials works until someone revokes it, and over time it gets copied into a .env file, a CI secret and a laptop backup. AWS's own IAM best practices ask humans to use federation and workloads to use roles with temporary credentials.

What are the ways to access AWS without access keys?

RankOptionWho it is forWhat replaces the access keyBest for
1EncoreDevelopers and AI agents building backendsNothing on their side: local infrastructure for development, and a role connected once for deploysTeams that want developers and agents to need no AWS credentials for day-to-day backend work
2aws loginPeople with console access (IAM users, roles, federation)Browser sign-in, temporary credentials for up to 12 hoursIndividual developers and small accounts
3IAM Identity CenterPeople in an organizationaws sso login against your identity providerCompanies with many accounts and an IdP such as Okta or Entra ID
4IAM roles for computeCode running on EC2, ECS, EKS or LambdaInstance profile, task role or execution roleEvery workload running inside AWS
5OIDC federationCI pipelines such as GitHub ActionsA role assumed per run with a signed tokenDeploy pipelines
6IAM Roles AnywhereServers and devices outside AWSX.509 certificates exchanged for temporary credentialsOn-premises servers and other clouds

Verdict: use Encore when the goal is that developers and agents need no AWS credentials for backend work, and the other five for the people and workloads that still call AWS directly. Most accounts need several rows of this table at once.

Why are long-term access keys the problem?

An access key never expires on its own, so its risk grows with every place it is copied. AWS describes temporary credentials as the alternative: they last from minutes to hours, they are not stored with the application, and they are issued again when they expire.

Scope is the other problem: a developer's access key usually carries the developer's full permissions, and any tool running in that shell, including a coding agent and the scripts it writes, can use it. A leaked deploy key in CI can do everything the pipeline can do, at any time, from anywhere.

How do developers sign in from the CLI without access keys?

If you sign in to the console as an IAM user, a role or through federation, use aws login. It needs AWS CLI 2.32.0 or later and the SignInLocalDevelopmentAccess managed policy on your IAM identity, opens a browser, and gives the CLI and SDKs temporary credentials:

~
$ aws login$ aws sts get-caller-identity$ aws logout

The session lasts up to 12 hours, and aws login --remote covers machines without a browser. If your company uses IAM Identity Center, run aws configure sso once and aws sso login each day instead, and access follows the permission sets your identity provider assigns.

How does code running on AWS get credentials?

Code on AWS gets credentials from a role attached to the compute. An EC2 instance gets an instance profile, an ECS task gets a task role, a Lambda function gets an execution role, and EKS pods get a role through EKS Pod Identity or IRSA. The AWS SDKs look for these credentials automatically through the default credential chain, so the code creates a client with no keys:

import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3"; // No accessKeyId or secretAccessKey: the SDK picks up the role's // temporary credentials from the task or instance metadata. const s3 = new S3Client({ region: "eu-west-1" }); await s3.send(new ListObjectsV2Command({ Bucket: "invoices-prod" }));

The role needs a policy that grants the calls the code makes, and keeping those policies narrow is the work that never goes away when you write the IAM yourself.

How does CI deploy to AWS without stored keys?

CI pipelines use OIDC federation instead of stored keys. GitHub signs a short-lived token for each workflow run, AWS checks it against an identity provider you registered, and the run assumes a role. GitHub's OIDC guide for AWS covers the identity provider and trust policy:

# .github/workflows/deploy.yml on: push: branches: [main] permissions: id-token: write # lets the job request the OIDC token contents: read jobs: deploy: runs-on: ubuntu-latest environment: production steps: - uses: actions/checkout@v7 - uses: aws-actions/configure-aws-credentials@v6 with: role-to-assume: arn:aws:iam::123456789012:role/github-deploy aws-region: eu-west-1 - run: ./scripts/deploy.sh

Restrict the role's trust policy with a sub condition such as repo:acme/shop:environment:production, so only that repository and environment can assume it, and add required reviewers to the production environment so a person approves each deploy. Pin each action to a full commit SHA rather than a tag, since the steps after the credentials step run with the deploy role.

What about servers and laptops outside AWS?

IAM Roles Anywhere gives workloads outside AWS the same temporary credentials. You register a certificate authority as a trust anchor, the server presents an X.509 certificate signed by it, and the signing helper exchanges it for credentials of a role you choose. It suits on-premises servers and jobs in other clouds that still read from S3 or write to SQS.

How do you stop developers and AI agents from needing AWS credentials at all?

Encore

The options above make credentials temporary, but developers and agents still hold them while they work. Encore removes the reason they need them. The backend declares the infrastructure it uses in code, encore run starts local versions of the databases, Pub/Sub topics and buckets on the laptop, and deploys go to your AWS account through an IAM role you connect once, protected by an external ID.

A service that stores uploads declares the bucket next to the endpoint that writes to it, with no AWS client and no keys:

// avatars/avatars.ts import { api, APIError } from "encore.dev/api"; import { getAuthData } from "~encore/auth"; import { Bucket } from "encore.dev/storage/objects"; // A local bucket under `encore run`, an S3 bucket in your AWS account once deployed. const avatars = new Bucket("avatars", { versioned: false }); // The key comes from the signed-in user, so nobody can overwrite another user's avatar. export const upload = api( { expose: true, auth: true, method: "POST", path: "/avatars" }, async ({ dataBase64 }: { dataBase64: string }): Promise<{ key: string }> => { const data = Buffer.from(dataBase64, "base64"); if (data.length > 1024 * 1024) throw APIError.invalidArgument("avatar must be 1 MB or smaller"); const key = `${getAuthData()!.userID}.png`; await avatars.upload(key, data, { contentType: "image/png" }); return { key }; }, );

When this is deployed, Encore creates the S3 bucket and gives the service access to that bucket only. Third-party keys go through Encore secrets, set with encore secret set and stored in AWS Secrets Manager in your account, so they do not sit in a .env file either.

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

Run in your terminal to get started locally.

For an AI coding agent, that means it adds the bucket, the topic or the database in the same change as the code that uses it and tests it locally, without an AWS profile in its shell. Production changes reach AWS only through a deploy, and each environment can require an Admin to approve infrastructure changes before they apply. Per the managing infrastructure docs, unused stateless resources are cleaned up automatically, and stateful resources such as databases, buckets and queues are not deleted unless they are unused and a user confirms the deletion.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders
An agent adds storage to a service and runs it under encore run, with no AWS credentials in its session. The same declaration becomes an S3 bucket when deployed.

Encore covers the infrastructure the backend declares, not the whole AWS account: people who use the console, data teams running queries and scripts that call other AWS services still need aws login or IAM Identity Center. Existing RDS databases can be connected to Encore while the rest of the account stays as it is.

Which option should you use?

  • Encore for backend development and deploys, so developers and AI agents need no AWS credentials for that work.
  • aws login for individuals who already sign in to the console and need the CLI now and then.
  • IAM Identity Center for companies with several accounts and an identity provider.
  • IAM roles for anything running inside AWS, always.
  • OIDC for every CI pipeline that still calls AWS.
  • IAM Roles Anywhere for servers outside AWS.

Delete the access keys that remain once each workload has moved, and use the IAM credential report to find keys that are still in use.

Frequently asked questions

Can I access AWS without access keys?

Yes. You still need credentials, since AWS authenticates every request, so the goal is to replace long-term access keys with temporary credentials: aws login or IAM Identity Center for people, an IAM role for code running on AWS, OIDC federation for CI and IAM Roles Anywhere for servers outside AWS. Each of these issues credentials that expire on their own.

What does the aws login command do?

aws login signs the AWS CLI in with the same credentials you use for the AWS Management Console, through a browser, and gives the CLI and SDKs temporary credentials for a session of up to 12 hours. It needs AWS CLI version 2.32.0 or later and the SignInLocalDevelopmentAccess managed policy on the IAM user or role. Teams on IAM Identity Center use aws sso login instead.

How does GitHub Actions deploy to AWS without stored keys?

GitHub Actions uses OIDC: you add GitHub as an identity provider in IAM, create a role whose trust policy only accepts tokens from your repository and branch, and the workflow uses aws-actions/configure-aws-credentials with role-to-assume. Each run gets temporary credentials for that role, and no access key is stored as a repository secret.

How do I stop developers and AI agents from needing AWS credentials?

Take deploys and secrets out of their sessions. With Encore, developers and agents declare the databases, Pub/Sub topics, buckets and secrets in the backend code and run them locally with encore run, which needs no AWS account. Deploys go to your AWS account through an IAM role you connect to Encore once, so developers and agents need no AWS keys to build, test or ship a backend change.

Should an AI coding agent ever get AWS credentials?

No. Production access should stay with a deploy system: the agent changes code and opens a pull request, and the deploy system ships the change after review. Short-lived credentials scoped to a sandbox account are fine for exploring.

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