Best Practices & Common Mistakes

A short checklist that prevents the most common AWS security incidents.

1 min read

Do this

  • Turn on MFA for the root user and every human.
  • Use roles for apps and services. Temporary credentials beat stored keys.
  • Follow least privilege. Start with the minimum and add permissions as errors show you what's needed.
  • Use IAM Identity Center for people, so they sign in once and get temporary credentials.
  • Review regularly. IAM Access Analyzer can flag resources shared outside your account and unused permissions.

Avoid this

MistakeWhy it hurtsBetter approach
Access keys in source codeBots scan public repos for keys within minutes.Use roles, or a local profile configured with aws configure sso.
Attaching AdministratorAccess "just to get it working"One bug or leak becomes a full-account compromise.Read the AccessDenied error and grant that specific action.
Sharing one user between teammatesYou can't tell who did what.One identity per person.
Never rotating or removing old keysForgotten keys are a silent risk.Delete unused keys, and check the "last used" date in the console.
Tip

An AccessDenied error is your friend. It tells you the exact action and resource that was blocked, which is precisely what to add to your policy, and nothing more.

Key takeaways

  • MFA, roles, and least privilege prevent most real-world incidents.
  • Never commit access keys to code. Use roles or SSO profiles instead.
  • Use AccessDenied errors to grow permissions one action at a time.

Check your understanding

Pick an answer to see the explanation.

  1. 1. Your script fails with AccessDenied on s3:PutObject. What's the best fix?

  2. 2. Which is the safest way for a person to get AWS CLI credentials?

Next in “Build a serverless AI app”
You finished IAM. Continue with the S3 tutorial