Managing Multiple AWS Accounts with CLI Profiles: A Practical Guide
Running work and personal AWS accounts from the same machine is a common reality for engineers — and without a proper profile strategy, you risk deploying personal side projects into your company's production account, or worse, billing your employer for your weekend experiments. TL;DR Step Action File Modified 1 Add named credentials ~/.aws/credentials 2 Add named config (region, output) ~/.aws/config 3 Use --profile flag per command CLI invocation 4 (Optional) Set AWS_PROFILE env var Shell session How AWS CLI Profile Resolution Works The AWS CLI uses a layered credential resolution chain. Named profiles are stored across two files: ~/.aws/credentials (access keys) and ~/.aws/config (region, output format, and advanced settings). The default profile is used when no profile is explicitly specified. Every other named profile must be referenced explicitly — either via the --profile flag or t...