Your AWS credentials are too powerful.
They unlock everything, everywhere, all at once. And that’s the problem.
The AWS CLI is a precision tool. By default, it runs with whatever IAM permissions are baked into your current credentials. For fast experiments, that’s fine. For production or sensitive workloads, it’s dangerous. Too many teams run with admin-level access because it’s easy. That convenience comes with the constant risk of mistakes, breaches, and compliance violations.
Fine-grained access control with AWS CLI–style profiles is the way out. By defining multiple named profiles, each with their own AWS access keys and scoped permissions, you can run commands with exactly the right level of access—no more, no less.
Why Profiles Matter
AWS CLI profiles are simple text configurations, usually found in ~/.aws/config and ~/.aws/credentials. Each profile maps to a specific IAM user, role, or SSO connection. Switching between them is as easy as adding --profile to any CLI command.
This is not a convenience trick. It’s a security strategy. Your “read-only” profile can query data without ever risking write operations. Your “dev” profile can spin up test infrastructure without touching production. Your “prod-deploy” profile can ship code but not delete resources.
Moving from Broad Access to Fine-Grained Control
The shift starts with killing the habit of using a single catch-all profile. Instead:
- Create IAM policies that reflect actual job functions.
- Associate each policy with a specific role or user.
- Store those in separate CLI profiles.
- Use
AWS_PROFILE=nameor--profile nameto run commands in the right context.
Example in ~/.aws/config: