Stop Sharing Keys: A Freelancer's Guide to Cross‑Account IAM Roles for Client AWS Access

If you manage multiple client AWS accounts, stop juggling long‑lived keys. Learn a practical cross‑account IAM roles workflow that’s safer and faster.

Written by: Rohan Deshpande

A laptop on a desk showing code and cloud diagrams on the screen, with a notebook and coffee nearby.
Image credit: Photo by Niels Steeman on Unsplash

I used to keep a spreadsheet of AWS access keys for every client, switching profiles like a frantic DJ changing records. It worked—for a while—until keys expired unexpectedly, a client rotated credentials without telling me, or worse, I accidentally ran a destructive command in the wrong account.

If you do client work on AWS in India (or anywhere), the cleaner, safer pattern is to use cross-account IAM roles. They cut out long‑lived keys, give clients control of permissions, and make switching between accounts predictable. Below I’ll walk through a practical workflow I use—what to ask clients for, how to configure your CLI, and the real tradeoffs you will hit after a few months of running this in production.

Why cross-account IAM roles, quickly

Main keyword: cross-account IAM roles (used naturally below).

What to ask your client

Before you start, ask the client for:

If the client can’t create roles (banking, regulated sectors) you’ll need to fall back to short‑lived keys or a dedicated user—more on that later.

How clients should create the role (what to suggest them)

A minimal trust policy they attach to the role might look like:

{ “Version”: “2012-10-17”, “Statement”: [ { “Effect”: “Allow”, “Principal”: { “AWS”: “arn:aws:iam::YOUR_ACCOUNT_ID:user/your-username” }, “Action”: “sts:AssumeRole”, “Condition”: {} } ] }

Better: they allow your team’s role or an external IdP. Encourage them to set a sensible maximum session duration (1 hour is common) and enable CloudTrail for auditability.

CLI setup: practical and reproducible

I prefer not to store user keys locally. Use one of these approaches.

  1. aws-vault (local secure keystore)

~/.aws/config [profile client-a] role_arn = arn:aws:iam::123456789012:role/ClientDeveloper source_profile = personal

When you run: aws-vault exec personal — aws s3 ls —profile client-a aws-vault handles assume-role and temporary credentials for you.

  1. Native AWS CLI profile chaining (no third‑party) ~/.aws/credentials [personal] aws_access_key_id = AKIA… aws_secret_access_key = …

~/.aws/config [profile client-a] role_arn = arn:aws:iam::123456789012:role/ClientDeveloper source_profile = personal region = ap-south-1

Then: AWS_PROFILE=client-a aws s3 ls

  1. AWS SSO / IAM Identity Center If either you or the client uses SSO, prefer it—no keys, centralised control, and federated access. Setup differs per tenant but it’s worth pushing clients toward it when possible.

Browser switching The AWS console also supports switching roles via the “Switch Role” option; keep a bookmark list of console URLs with role session names to avoid confusion. For regular client work I keep role session names like “rohan-freelance” so CloudTrail is readable.

A practical example: rotating into a client account

Say you need to run migrations and deploy a Lambda:

Constraints and tradeoffs (real talk)

A small, India‑specific tip

Many Indian clients have internal compliance requirements—ask early whether they require a signed NDA, IP assignment, or a specific audit trail. Propose cross-account roles as part of onboarding; it’s a low‑cost win for their security team and your sanity.

When cross-account roles aren’t enough

For CI pipelines that must run unattended, I often recommend:

Conclusion

If you freelance with AWS accounts, adopting cross-account IAM roles is one of those small infrastructure changes that pays back in time, fewer surprises, and better security. It’s not perfect—some clients won’t cooperate, and role session limits can bite—but when it’s available it replaces brittle key-spreadsheet workflows with something reliable and revocable.

Try it on your next client onboarding: ask for a role ARN, configure one CLI profile, and notice how much less you worry about keys. If the client resists, you’ve already got a conversation starter that’s framed around auditability and least privilege—two things finance and compliance teams actually like hearing.