# How to switch between AWS profiles

How-to guides · Updated 16 November 2026

**Short answer:** Pass --profile name on a single command, or export AWS_PROFILE=name to switch the whole shell. aws configure list-profiles shows every profile you have, and aws configure list shows which one is active and where its credentials come from. For IAM Identity Center profiles, one aws sso login per sso-session signs in every profile that shares it.

## Switching

```
# See what you have
aws configure list-profiles

# One command
aws s3 ls --profile staging

# Whole shell (bash/zsh)
export AWS_PROFILE=staging
# PowerShell
$Env:AWS_PROFILE = "staging"

# Confirm
aws configure list
aws sts get-caller-identity
```

`unset AWS_PROFILE` returns you to the `default` profile.

## What wins when several are set

| Priority | Source |
|---|---|
| 1 (highest) | `--profile` on the command line |
| 2 | `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN` environment variables |
| 3 | `AWS_PROFILE` |
| 4 | The `[default]` profile |

The trap is row 2: leftover key variables from an earlier `assume-role` silently override `AWS_PROFILE`. If `aws configure list` shows `env` as the credential type, unset them.

## SSO profiles: list them and log in once

Modern IAM Identity Center configuration splits the login (an `sso-session`) from the profiles that use it:

```
# ~/.aws/config
[sso-session acme]
sso_start_url = https://acme.awsapps.com/start
sso_region = eu-west-2
sso_registration_scopes = sso:account:access

[profile acme-dev]
sso_session = acme
sso_account_id = 111122223333
sso_role_name = Developer
region = eu-west-2

[profile acme-prod-ro]
sso_session = acme
sso_account_id = 123456789012
sso_role_name = ReadOnly
region = eu-west-2
```

```
# One login covers both profiles
aws sso login --sso-session acme

# Check each profile works with the shared token
aws sts get-caller-identity --profile acme-dev
aws sts get-caller-identity --profile acme-prod-ro
```

`aws configure sso` walks you through creating these entries and lets you pick from the accounts and roles your user can access, which is the easiest way to add profiles for every account. There is no single command that logs in to several *different* sso-sessions at once; run `aws sso login` for each.

## Make the active profile visible

Most wrong-account accidents happen because nobody can see which profile a terminal is using. Two cheap habits help:

- **Show it in your prompt.** In bash, adding `${AWS_PROFILE:-default}` to `PS1` prints the active profile before every command. Many shell themes have an AWS segment that does the same.
- **Name profiles after account and access level**, for example `acme-prod-ro` and `acme-prod-admin`, so a read-only profile is the obvious default and the admin one is a deliberate choice.
- **Use separate terminal windows per environment** rather than exporting a new profile in the same shell, and close the production one when you are done.

## Common mistakes

- **Wrong section header.** In `~/.aws/config` it is `[profile staging]`; in `~/.aws/credentials` it is `[staging]`. Mixing them gives ["The config profile could not be found"](https://cloudconsole.dev/errors/config-profile-could-not-be-found).
- **Region per profile.** Each profile can have its own `region`; switching profile can silently switch Region too.
- **Old-style SSO profiles** with `sso_start_url` inside each profile need a separate login per profile and don't refresh tokens automatically. Moving them to an `sso-session` section fixes both.

## Questions

### How do I see which AWS profile I am using?

Run aws configure list. It shows the profile name and whether credentials came from the environment, a config file or SSO. aws sts get-caller-identity confirms the account and role.

### How do I log in to all my AWS SSO profiles at once?

Put them under one sso-session section and run aws sso login --sso-session with that name. Every profile referencing the session uses the same token.

### Is AWS_DEFAULT_PROFILE the same as AWS_PROFILE?

Use AWS_PROFILE. It is the variable documented for the AWS CLI and understood by the AWS SDKs.

## When this happens away from your desk

Juggling profiles is fiddly at a desk and worse on the move. CloudConsole, a phone app for AWS, is built to switch between accounts on your phone while keeping production clearly marked.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Configuration and credential file settings in the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
- [Configuring IAM Identity Center authentication with the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html)

## Related

- [aws configure list-profiles](https://cloudconsole.dev/cli/configure-list-profiles)
- [aws configure sso](https://cloudconsole.dev/cli/configure-sso)
- [aws sso login](https://cloudconsole.dev/cli/sso-login)
- [How to log in to AWS SSO from the CLI](https://cloudconsole.dev/how-to/aws-sso-login-cli)
- [The config profile (name) could not be found](https://cloudconsole.dev/errors/config-profile-could-not-be-found)
- [How to switch role with the AWS CLI](https://cloudconsole.dev/how-to/switch-role-aws-cli)

---

Source: https://cloudconsole.dev/how-to/switch-between-aws-profiles

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
