That’s the reality when AWS CLI access is wide open. One wrong credential push, one misconfigured profile, and your infrastructure is exposed. The only way forward is controlled, minimal, and auditable access from the ground up.
AWS CLI restricted access is not just a security checkbox. It’s an operational standard. Start by defining the smallest set of permissions possible using IAM policies. Group CLI users by role, not name. Avoid wildcard actions. Every command should run with the principle of least privilege, even if that means creating more granular roles.
Enable MFA for every identity that can use the CLI. Combine MFA with short-lived session tokens from AWS STS so long-term keys never hit disk. Keep credentials encrypted at rest, even on developer machines. Use environment variables and avoid static credential files when possible. Audit command history. The --profile flag is a tool, but also a liability if default profiles have overly broad access.
Centralize logging for all CLI activity. AWS CloudTrail must capture every API call triggered via the CLI. Review these logs regularly, not just after incidents. Attach conditions to IAM policies to restrict CLI usage to known IP ranges or VPC endpoints. This stops stolen keys from working outside your network.