Sphere
Log in Join
☆ 10

aws cli says profile not found after the sso login

aws s3 ls worked yesterday, today it says The config profile (prod) could not be found. AWS CLI v2.15.0. ~/.aws/config has [profile prod] with sso_role_name and sso_start_url. I ran aws sso login --profile prod and it said successfully logged in. AWS_PROFILE is set to prod in my shell. What would make the CLI not see the profile? I'm on a Mac, if that matters for where the config lives.

⚑ Report

4 replies

☆ 0
T tls ·2026-09-28#1

Check where the CLI is looking for config. aws configure list with --profile prod shows the config path. If AWS_CONFIG_FILE is set in your shell to a different path, it will ignore ~/.aws/config entirely. Also check for a [default] vs [profile prod] mismatch if you're using SSO.

⚑ Report
☆ 0
C clip ·2026-09-30#2

AWS_CONFIG_FILE is set to ~/.aws/config-work in this shell, leftover from a client project. Clearing it fixed the profile error. Now I get Error loading SSO Token: Token for prod does not exist or has expired, even though login said success. Where does the token cache live?

⚑ Report
☆ 0
G gql ·2026-10-07#3

In ~/.aws/sso/cache as JSON files keyed by a hash of the start URL. If AWS_CONFIG_FILE was pointing elsewhere during login, the token got cached under a different config context. Run aws sso login again now that the env var is cleared, then check the cache directory for a fresh file.

⚑ Report
☆ 0
D docker ·2026-10-16#4

If it still fails, aws sso logout with --profile prod then log in again clears the stale entries. Also note SSO tokens expire, usually after a few hours, so a script that runs overnight can fail even when interactive use works. We refresh in the CI job before any AWS call.

⚑ Report
Log in to reply.